Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.flatMap(isLoaded =>
isLoaded ?
// ensures async consistency
Kefir.later(0, true) :
Kefir.fromEvents(document, 'DOMContentLoaded')
)
// and end it there. Or end after a timer.
Kefir.fromEvents(window, 'mousemove')
.bufferBy(Kefir.interval(60, null))
.map(events => {
if (events.length) {
const last = events[events.length-1];
lastCoords = {pageX: last.pageX, pageY: last.pageY};
}
return lastCoords;
})
.filter(({pageX, pageY}) => {
const distance = getDistance(pageX, pageY);
const maxDistance = startDistance - (Date.now()-startTime-LEAD_TIME)/1000 * MIN_SPEED;
return distance > maxDistance;
})
.merge(Kefir.later(MAX_TIME*1000))
.take(1)
.takeUntilBy(this._resetMouseLeaveWatcher)
.takeUntilBy(this._stopper)
.onValue(() => {
this.close();
menuItem.unhighlight();
});
}
let bar: Property = Kefir.sequentially(200, [false, true, false]).delay(40).toProperty(() => true);
let observable01: Stream = foo.filterBy(bar);
}
{
let a: Property = Kefir.sequentially(200, [2, 3]).toProperty(() => 1);
let b: Stream = Kefir.interval(100, 0).delay(40).take(5);
let observable02: Property = a.sampledBy(b)
}
{
let foo: Stream = Kefir.sequentially(100, [1, 2, 3, 4]);
let bar: Stream = Kefir.later(250, 0);
let observable03: Stream = foo.skipUntilBy(bar);
}
{
let foo: Stream = Kefir.sequentially(100, [1, 2, 3, 4]);
let bar: Stream = Kefir.later(250, 'hello');
let observable04: Stream = foo.takeUntilBy(bar);
}
{
let foo: Stream = Kefir.sequentially(100, [1, 2, 3, 4, 5, 6, 7, 8]).delay(40);
let bar: Stream = Kefir.sequentially(300, [1, 2])
let observable05: Stream = foo.bufferBy(bar);
}
{
let foo: Stream = Kefir.sequentially(100, [1, 2, 3, 4, 5, 6, 7, 8]);
let bar: Stream = Kefir.sequentially(200, [false, true, false]).delay(40);
let observable06: Stream = foo.bufferWhileBy(bar);
}
{
let foo: Stream = Kefir.sequentially(100, [1, 2, 3]);
let bar: Stream = Kefir.sequentially(100, [1, 2, 3]).delay(40);
let observable07: Stream = foo.awaiting(bar);
{[Kefir.constant('Hel'), [Kefir.constant('lo')]]}
,
'<div style="display:block;color:red;background:green">Hello</div>'
)
testRender(
<a href="{Kefir.constant('#lol')}" style="{Kefir.constant({color:">
{Kefir.constant('Hello')} {Kefir.constant('world!')}
</a>,
'<a href="#lol" style="color:red">Hello world!</a>'
)
testRender(
<div>
{Kefir.constant(1)
.merge(Kefir.later(1000, 0))
.toProperty()}
</div>,
'<div>1</div>'
)
const Custom = ({prop, ...props}) => (
<div>{`${prop} ${JSON.stringify(props)}`}</div>
)
testRender(
,
'<div>[constant] {}</div>'
)
testRender(
,
'<div><div>a</div><div>b</div><div>c</div><div>d</div></div>'
)
testRender(
<div>
<div>a</div>
{[
<div>b</div>,
Kefir.constant([<div>c</div>, [<div>d</div>]])
]}
</div>,
'<div><div>a</div><div>b</div><div>c</div><div>d</div></div>'
)
testRender(
<div>,
'<div>foo</div>'
)
const ChildrenWithSibling = ({children}) => <div>Test: {children}</div>
testRender(
Hello {Kefir.constant('world!')},
'<div>Test: Hello world!</div>'
)
testRender(<span>0</span>, '<span>0</span>')
testRender(<span>{Kefir.constant(0)}</span>, '<span>0</span>')
testRender(
<div>,
'<div>oh yes</div>'</div></div>
_onHighlightChange(highlighted: boolean, event: Object) {
this._resetMouseLeaveWatcher.emit(null);
if (highlighted && !event.byKeyboard) {
const OPEN_DELAY = 200;
Kefir.later(OPEN_DELAY)
.takeUntilBy(this._resetMouseLeaveWatcher)
.takeUntilBy(this._stopper)
.onValue(() => {
this.open();
});
} else if (!highlighted) {
this.close();
}
}
let timeoutError = (delayMs) =>
K.later(delayMs, K.constantError(new Error("timeout"))).flatMap()
return (actions$: Observable): Observable => {
const initial$ = Kefir.later(0, router(getRoute(window.location.search, param)));
const pushState$ = actions$.thru(ofType(routeChange)).flatMap(({ payload }: RouteChangeAction) => Kefir.stream((emitter: Emitter) => {
const dest = getUrl(param, payload);
if (dest !== (location.pathname + location.search)) {
global.history.pushState({}, '', dest);
}
emitter.end();
}));
const href$ = Kefir.stream((emitter: Emitter) => {
const emit = ({ search, href }: HrefTarget) => {
if (typeof search === 'string') {
search = parseQueryString(search);
}
const prompt$ = state$.take(1).flatMap(state =>
state.command.opts.yes === true
? Kefir.later(0, initConfigResponse({ ...defaultConfig, name: state.command.args.name }))
: ui.prompt([
{
type: 'input',
name: 'version',
message: 'What is the application version?',
default: defaultConfig.version
},
{
type: 'input',
name: 'description',
message: 'What is the application description?',
default: defaultConfig.description
},
{
type: 'input',
name: 'dir',
.flatMap(v => Kefir.later(0, v))
).observe({