Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(props, context) {
super(props, context);
const observables = get(context.stores);
// Create a combined stream that maps all the observables to a
// single state value for the react component.
this.property = combine(state, observables);
}
exports.main = function() {
// x represents the current value of xInput
var x = most.fromEvent('input', xInput).map(toNumber);
// x represents the current value of yInput
var y = most.fromEvent('input', yInput).map(toNumber);
// result is the live current value of adding x and y
var result = most.combine(add, x, y);
// Observe the result value by rendering it to the resultNode
result.observe(renderResult);
};
// array of threads
for (let i = 0; i < cur.length; i++) {
let thread = map[cur.id] || {id: cur.id}
for (let k in cur[i]) {
thread[k] = cur[i][k]
}
map[cur[i].id] = thread
}
} else {
// single thread
map[cur.id] = cur
}
return map
}, {})
let vtree$ = most.combine(({value}, threads, storage) =>
h('div', [
vrender.nav(),
fwitch(value.where, {
'THREADS': () => vrender.list({threads}, storage['typed.']),
'THREAD': () =>
threads[value.id]
? vrender.standalone(threads[value.id], storage[`typed.${value.id}`])
: vrender.empty()
})
])
,
match$,
threadMap$,
STORAGE.all$
)
.map(x => x || vrender.empty())
bot: most.from([
most.of(sendGame(
{ chat_id: GROUP_ID,
game_short_name: 'test' },
{})),
bot.events('message')
.map(x => x.message.from)
.tap(() => bot.dispose())
.combine((user, message) => ({ message, user }), bot.responses.take(1))
.map(({ message, user }) =>
getGameHighScores(
{ user_id: user.id, message_id: message.message_id },
{ message })),
most.combine(
([message, user], score) => ({ message, user, score }),
bot.responses
.take(1)
.combine(
(message, user) => [message, user],
bot.events('message').tap(() => bot.dispose()).map(x => x.message.from)),
bot.responses
.skip(1)
.filter(Array.isArray)
.flatMap(most.from))
.filter(({user, score}) => user.id === score.user.id)
.map(({ score: { score }, user, message }) =>
setGameScore(
{ score: score + 1, user_id: user.id, message_id: message.message_id },
{ message })),
const aperture = () => {
const visible$ = fromEvent('visibilitychange', document)
.map(isVisible)
.startWith(isVisible())
const online$ = merge(
fromEvent('online', window).map(() => true),
fromEvent('offline', window).map(() => false)
).startWith(isOnline())
return combine((online, visible) => online && visible, online$, visible$)
.skipRepeats()
.map(
onlineAndVisible =>
onlineAndVisible
? periodic(10)
.map(() => ({
type: 'TICK'
}))
.startWith({ type: 'RESUME' })
: MostOf({ type: 'PAUSE' })
)
.switchLatest()
}
.add('most', function (deferred) {
var source = most.from(a);
var inc = source.filter(isPositive).map(returnPlus1);
var dec = source.filter(isNegative).map(returnMinus1);
var count = most.merge(inc, dec).scan(addXY, 0);
var label = most.from(['initial', 'Count is ']);
var view = most.combine(renderWithArgs, label, count);
runners.runMost(deferred, view.drain());
}, options)
.add('rx 6', function (deferred) {
});
return { $state: $state, $props: $props };
},
metadata: {
instance: _this
}
}),
id = _MirrorBackend$addSto.id,
path = _MirrorBackend$addSto.path,
mirror = _MirrorBackend$addSto.mirror,
dispatch = _MirrorBackend$addSto.dispatch,
streams = _MirrorBackend$addSto.streams;
Object.assign(_this, { id: id, depth: path.length, mirror: mirror, dispatch: dispatch });
var $propsState = streams.$state ? most.combine(instantiseMapToProps(mapToProps.bind(_this)), streams.$state, streams.$props) : streams.$props.map(instantiseMapToProps(mapToProps.bind(_this, undefined)));
$propsState.skipRepeatsWith(pure.propsStateEqual.bind(_this)).thru(scheduler.addStream.bind(null, _this.depth, id)).observe(function (propsState) {
_this._propsState = propsState;
if (_this._unmounted) return;
_this.setState(function (_ref2) {
var updateCount = _ref2.updateCount;
return {
updateCount: updateCount + 1,
propsState: propsState
};
});
}).then(scheduler.removeStream.bind(null, id));
return _this;
}
.add('most', function (deferred) {
var source = most.from(a);
var inc = source.filter(isPositive).map(returnPlus1);
var dec = source.filter(isNegative).map(returnMinus1);
var count = most.merge(inc, dec).scan(addXY, 0);
var label = most.from(['initial', 'Count is ']);
var view = most.combine(renderWithArgs, label, count);
runners.runMost(deferred, view.drain());
}, options)
.add('rx 5', function (deferred) {
vTree => {
if (!vTree) {
return null
} else if (vTree.observe) {
return vTree.map(vTreeParser).switch()
} else if (`object` === typeof vTree) {
const vTree$ = most.just(vTree)
if (vTree.children && vTree.children.length > 0) {
return most.combine(
combineVTreeStreams,
vTree$,
...filter(
map(vTree.children, vTreeParser),
x => x !== null
)
)
}
return vTree$
} else {
throw new Error(`Unhandled tree value`)
}
}
if (!state || !$state || !$state.subscribe) return { $props };
$state = $state
.skipRepeatsWith(pure.stateEqual.bind(this))
.filter(state => state !== undefined)
.tap(state => (this._state = state));
return { $state, $props };
},
metadata: {
instance: this
}
}
);
Object.assign(this, { id, depth: path.length, mirror, dispatch });
const $propsState = streams.$state
? most.combine(
instantiseMapToProps(mapToProps.bind(this)),
streams.$state,
streams.$props
)
: streams.$props.map(
instantiseMapToProps(mapToProps.bind(this, undefined))
);
$propsState
.skipRepeatsWith(pure.propsStateEqual.bind(this))
.thru(scheduler.addStream.bind(null, this.depth, id))
.observe(propsState => {
this._propsState = propsState;
if (this._unmounted) return;
this.setState(({ updateCount }) => ({
updateCount: updateCount + 1,