Skip to content

Commit

Permalink
fix(examples): minor updates/fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Dec 21, 2019
1 parent 19c834e commit fd31880
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
39 changes: 21 additions & 18 deletions examples/mandelbrot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ const newRender = (
};

const updateZoom = (zoom: number) => {
let _x1 = x1.deref();
let _y1 = y1.deref();
let _x2 = x2.deref();
let _y2 = y2.deref();
let _x1 = x1.deref()!;
let _y1 = y1.deref()!;
let _x2 = x2.deref()!;
let _y2 = y2.deref()!;
newRender(
mix(_x1, _x2, zoom),
mix(_y1, _y2, zoom),
Expand Down Expand Up @@ -134,10 +134,10 @@ const app = () => {
smooth: 1e-3
}).subscribe({
next([type, { pos, zoom }]: any) {
const _x1 = x1.deref();
const _y1 = y1.deref();
const _x2 = x2.deref();
const _y2 = y2.deref();
const _x1 = x1.deref()!;
const _y1 = y1.deref()!;
const _x2 = x2.deref()!;
const _y2 = y2.deref()!;
switch (type) {
case GestureType.START:
sel1.next(pos);
Expand Down Expand Up @@ -182,10 +182,10 @@ const app = () => {
});
// key controls fine tuning region
window.addEventListener("keydown", (e) => {
let _x1 = x1.deref();
let _y1 = y1.deref();
let _x2 = x2.deref();
let _y2 = y2.deref();
let _x1 = x1.deref()!;
let _y1 = y1.deref()!;
let _x2 = x2.deref()!;
let _y2 = y2.deref()!;
const amp = e.shiftKey ? 0.1 : 0.01;
const deltaX = (_x2 - _x1) * amp;
const deltaY = (_y2 - _y1) * amp;
Expand Down Expand Up @@ -294,12 +294,15 @@ const slider = (
main.transform(map(app()), updateDOM());

// init parameter streams, if possible from location.hash
newRender.apply(null, <any>(location.hash.length > 1
? location.hash
.substr(1)
.split(";")
.map(parseFloat)
: DEFAULT_CONFIG));
newRender.apply(
null,
<any>(location.hash.length > 1
? location.hash
.substr(1)
.split(";")
.map(parseFloat)
: DEFAULT_CONFIG)
);

// HMR handling
if (process.env.NODE_ENV !== "production") {
Expand Down
2 changes: 1 addition & 1 deletion examples/rstream-event-loop/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ defHandler(
// don't allow event if new page ID would be negative
filter(([_, x]) => state.deref()!.pageID >= x!)
// alternatively, use `map()` transducer to clamp new pageID to 0
// map((e) => state.deref().pageID < e[1]! ? [PREV, state.deref().pageID] : e)
// map((e) => state.deref()!.pageID < e[1]! ? [PREV, state.deref()!.pageID] : e)
);

defHandler(
Expand Down
2 changes: 1 addition & 1 deletion examples/shader-ast-workers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ forkJoin<number, WorkerJob, WorkerResult, void>({
updatePixels(parts);
drawStats(parts);
// trigger next update
time.next(time.deref() + 0.05);
time.next(time.deref()! + 0.05);
},
worker: "./worker.js",
numWorkers: NUM_WORKERS
Expand Down

0 comments on commit fd31880

Please sign in to comment.