Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function runGame (mount, gameId) {
/// States ///
var speed, refreshRate;
var playing = false;
var game = null;
var buffered = 0;
/// Streams ///
// The game stream is cached once forever
var gameStream = new Rx.ReplaySubject();
GameStream(gameId).subscribe(gameStream);
var gameInterruptions = new Rx.Subject();
var refreshRateStream = Rx.Observable.generateWithRelativeTime(0, alwaysTrue, increment, identity, function () { return refreshRate; });
// Functions
function render () {
if (!game) return; // Nothing to render yet
React.renderComponent(Game({
game: game,
refreshRate: refreshRate,
increaseSpeed: increaseSpeed,
decreaseSpeed: decreaseSpeed,
play: play,
pause: pause,
jump: jump,
.scan((prevPage, navi) => {
// Unsubscribe previous page (if there was)
if (prevPage && prevPage.subscriptions) {
prevPage.subscriptions.forEach((s) => s.dispose())
}
// Make disposable sinks
let sinkProxies = {
redirect: new ReplaySubject(1),
update: new ReplaySubject(1),
DOM: new ReplaySubject(1),
log: new ReplaySubject(1),
state2: new ReplaySubject(1),
}
// Run page
let sinks = merge({
redirect: $.empty(), // affects navi
update: $.empty(), // affects state
log: $.empty(), // affects log
DOM: $.empty(), // affects DOM
state2: $.empty(), // nested state loop
}, navi.page(merge(src, {state2: sinkProxies.state2})))
// Subscribe current page
let subscriptions = [
const main = ({ DOM, HTTP: string }) => {
const __Proxy0 = new ReplaySubject(1);
var component1 = Component1({ value$: __Proxy0.finally(() => {
if (__Proxy0.observers.length === 0) __Proxy0_Sub.dispose();
}), DOM });
var component2 = Component2({ HTTP });
const __Proxy0_Sub = component2.value$.subscribe(__Proxy0);
return {
DOM: component1.DOM,
HTTP: component2.HTTP
};
};
function Store(state) {
_classCallCheck(this, Store);
this.subject = new Rx.ReplaySubject(1);
this.updateState(state);
}
value: function get(streamKey, comparer = defaultComparer) {
if (typeof streamKey === 'undefined') {
throw new Error('Custom element driver `props.get()` expects an ' +
'argument in the getter.');
}
if (typeof this[streamKey] === 'undefined') {
this[streamKey] = new Rx.ReplaySubject(1);
}
return this[streamKey]
.distinctUntilChanged(Rx.helpers.identity, comparer);
}
});
export function fromGenerator(gen) {
gen = isGeneratorFunction(gen) ? gen() : isGenerator(gen) ? gen : null;
const sub$ = new ReplaySubject(1);
function onNext(value) {
sub$.onNext(value);
let ret;
try {
ret = gen.next(value);
} catch(e) {
return sub$.onError(e);
}
processNext(ret);
}
function onError(err) {
let ret;
try {
ret = gen.throw(err);
} catch(e) {
return sub$.onError(e);
export default function DynamicGifViewer(sources) {
const { DOM, HTTP, initialTopics } = sources;
/*
* Input
*/
const input = isolate(Input, Uuid.v4())({DOM});
/*
* Subjects
*/
const requestSub = new Rx.ReplaySubject();
const morePleaseSub = new Rx.Subject();
const vtreeSub = new Rx.Subject();
/*
* Viewers
*/
const appendViewer = topic => {
const id = Uuid.v4();
const viewer = isolate(RemovableGifViewer, id)({DOM, HTTP, topic, id});
viewer.HTTP.subscribe(request => requestSub.onNext(request));
viewer.morePlease$.subscribe(() => morePleaseSub.onNext('MORE PLEASE!'));
viewer.DOM.subscribe(vtree => vtreeSub.onNext({type: 'UPDATED', payload: {id, vtree}}));
viewer.remove$.subscribe(() => vtreeSub.onNext({type: 'REMOVAL_REQUESTED', payload: {id}}));
}
setUpTable: function () {
var containerHeight = this.props.containerHeight;
var rowHeight = this.props.rowHeight;
var rowCount = this.props.rowCount;
var visibleRows = Math.ceil(containerHeight/ rowHeight);
var getScrollTop = () => {
return this.containerNode.scrollTop;
};
var initialScrollSubject = new Rx.ReplaySubject(1);
initialScrollSubject.onNext(getScrollTop());
var scrollTopStream = initialScrollSubject.merge(
Rx.Observable.fromEvent(this.containerNode, 'scroll').map(getScrollTop)
);
var firstVisibleRowStream = scrollTopStream.map(function (scrollTop) {
return Math.floor(scrollTop / rowHeight);
}).distinctUntilChanged();
var visibleIndicesStream = firstVisibleRowStream.map(function (firstRow) {
var visibleIndices = [];
var lastRow = firstRow + visibleRows + 1;
if (lastRow > rowCount) {
firstRow -= lastRow - rowCount;
import Rx from 'rx';
import update from 'react/lib/update';
import Intent from './../intent/Json-intent';
var subject = new Rx.ReplaySubject(1);
var state = {
postResult: [],
results: []
};
Intent.subjects.goGetJSON.subscribe((data) => {
state = update(state, {
$merge: {
results: data
}
});
subject.onNext(state);