Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function restartable (driver, opts = {}) {
const {log$, addLogEntry, replaceLog} = createLog$();
// TODO - dispose log subscription
log$.addListener(subscribe(() => {}));
const streams = {};
const pauseSinksWhileReplaying = opts.pauseSinksWhileReplaying === undefined ? true : opts.pauseSinksWhileReplaying;
const pause$ = (opts.pause$ || xs.empty()).startWith(true);
const replayOnlyLastSink = opts.replayOnlyLastSink || false;
let replaying;
const isReplaying = () => replaying;
const setReplaying = (newReplaying) => replaying = newReplaying;
const finishedReplay$ = xs.create();
function restartableDriver (sink$, Time) {
const filteredSink$ = xs.create();
const lastSinkEvent$ = xs.createWithMemory();
if (sink$) {
if (isReplaying() && replayOnlyLastSink) {
lastSinkEvent$.map(lastEvent => finishedReplay$.mapTo(lastEvent)).flatten().take(1).addListener(subscribe((event) => {
filteredSink$.shamefullySendNext(event);
}));
function Collection (component, sources = {}, sourceAdd$ = xs.empty(), removeSelector = noop) {
const removeProxy$ = xs.create();
const add$ = xs.fromObservable(sourceAdd$);
const addReducer$ = add$.map(sourcesList => collection => {
if (Array.isArray(sourcesList)) {
// multiple items
return sourcesList.reduce((collection, sources) => collection.add(sources), collection);
} else {
// single item
return collection.add(sourcesList);
}
});
const removeReducer$ = removeProxy$.map(item => collection => collection.remove(item));
const reducer$ = xs.merge(removeReducer$, addReducer$);
const emptyCollection = collection({ component, sources, removeSelector });
const collection$ = reducer$
public select(selector: string): HTMLSource {
return new HTMLSource(xs.empty(), this._name);
}
constructor(html$: Stream, private _name: string) {
this._html$ = html$;
this._empty$ = adapt(xs.empty());
}
public select(selector: string): DOMSource {
return new HTMLSource(xs.empty(), this._name);
}
public events(eventType: string): Stream {
if (this._selector === null) {
return adapt(xs.empty());
} else {
return adapt(this._scope.getHandler(this._selector, eventType));
}
}
add (additionalSources = {}) {
const newItem = makeItem(component, {...sources, ...additionalSources});
const selectedSink = removeSelector(newItem) || xs.empty();
const removeSink = xs.fromObservable(selectedSink);
newItem._remove$ = removeSink.take(1).mapTo(newItem);
return collection(
options,
[...items, newItem]
);
},
constructor(private _mockConfig: MockConfig) {
if (_mockConfig.elements) {
this._elements = _mockConfig.elements as FantasyObservable;
} else {
this._elements = adapt(xs.empty());
}
}
const rootElementWithDefaults = Object.assign(
{},
defaults,
rootElement
)
const instructions = translateVtreeToInstructions(rootElementWithDefaults)
renderInstructionsToCanvas(instructions, context)
},
error: e => { throw e },
complete: () => null
})
return adapt(xs.empty())
}
public events(eventType: string): Stream {
if (this.selector === null) {
return adapt(xs.empty());
} else {
return adapt(this.ctx.getHandler(this.selector, eventType));
}
}
}