Skip to content

Instantly share code, notes, and snippets.

@FbN
Created November 1, 2019 13:16
Show Gist options
  • Save FbN/eb12809df533f33aa53191084a24804a to your computer and use it in GitHub Desktop.
Save FbN/eb12809df533f33aa53191084a24804a to your computer and use it in GitHub Desktop.
Most/Core Version
function todoList (deferred) {
const ping$ = fromArray([...Array(config.iterations).keys()])
const todo$ = multicast(map(todo, ping$))
const old$ = merge(
map(todo => (todo.id % 4 === 0 ? todo : {}), take(1, todo$)),
filter(todo => todo.id % 4 === 0, skip(1, todo$))
)
const sample$ = snapshot(
(old, last) => ({...last, old}),
old$,
todo$
)
const list$ = scan((list, item) => [...list, item], [], sample$)
const end$ = take(
1,
filter(list => list.length === config.iterations, list$)
)
return tap(res => deferred.resolve(res), end$)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment