baconjs / bacon.js

Functional reactive programming library for TypeScript and JavaScript

Home Page:https://baconjs.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Figuring out join combinators.

alexander-matsievsky opened this issue · comments

Good day!

Please take a look at this. It is an implementation of a reference TodoMVC app.

The solution works as advertised. Nevertheless, I feel I'm missing something about joining streams.

update function

At first I though that would work:

if (error) {
  return new Bacon.Error(error);
} else {
  return new Bacon.Next([todos, todo]);
}

but had to settle for a solution with node-like running state:

if (error) {
  return [todos, error, null];
} else {
  return [todos, null, todo];
}

Is my reasoning flawed?

when joins

The update stream holds the the current todo-list :Todo[] and the last change with full info :Todo (whether creation, update or deletion). This code block extracts this change in a categorized way. My question is whether I'm doing it right or there is a better way to handle a situation like

POST triggered an update. Get the events from update initiated by POST and skip the ones triggered by PUT and DELETE.

@raimohanska Could you help me out with the above issue?

sorry I'm a bit busy. maybe someone else has time to review the code?

@raimohanska Yes, of course. Thanx for an amazing library!+)