These are chat archives for jdubray/sam

Jun 2016
Michael Terry
Jun 17 2016 03:18
@jdubray this is relevant to your interests
Jean-Jacques Dubray
Jun 17 2016 05:40


also, given the reactive flow, would you achieve the composition by passing A as the presentfn in B?

Yes, that's a reasonable way to achieve it (pipeline style). All my action signatures have an option reference to a present method, in that case, it would be a reference to the next action.

I really want to emphasize that logically you are not executing "two actions" because the model has not mutated after the first one, it is only a structural composition. A logical composition (execute action 1, then action 2)would have to be handled by the next-action-predicate (nap).

Jean-Jacques Dubray
Jun 17 2016 06:06
@formido I'll take a look but to be honest, the more I learn about RxJS, the more I dislike it. That kind of programming model is deeply flawed. I am not surprised Erik Meijer never answered my question.
Jean-Jacques Dubray
Jun 17 2016 06:11

For instance, when using Angular (not sure about other frameworks) to build data services you need to use this magical "share" property on your observable otherwise you get echos of your requests... That gives you a wonderful feeling of robustness.

It took me a full day to figure it out (not well documented). The "effects" are very real, when I created a record, I got 3+ requests to create that record. When you trace your code, you see only one request of course... it's all done via the observable. Aside from these little "glitches" the logical problem with observables is that you are trapped in dedicated data flows, that makes no sense at all, from a mutation perspective. The event does not drive the mutation, it drives the proposal.

How about adopting mutation as a first class of the programming model? (considering that counter = counter + 1 is not the way mutations occur)
Don't you think it would be about time to do so?
Jean-Jacques Dubray
Jun 17 2016 14:02
This message was deleted
I continued to explore the ng2Rx Todo sample and here is how it is wired:
Interesting that the author use the word "intent" (as opposed to action). Intents observe values, which are passed to a reducer. An intent looks like this:
toggleTodo$: makeObservableFunction<{ id: string }>(this, 'toggle')
Which triggers the toggleTodoReducer$:
const toggleTodoReducer$ = intent.toggleTodo$
        .map(({ id }) => (todosStore: TodosStore) => ({
            todos: => !== id ? todo : Object.assign({}, todo, { completed: !todo.completed }))
Jean-Jacques Dubray
Jun 17 2016 14:08
I found interesting too that the author use view model in a similar way to the one I suggested for SAM (I am not implying that the author copied, that's really common sense)
Here is what it looks like:
export function createViewModel(todosStore: TodosStore, filter: string) {
    const numTodos = todosStore.todos.length;
    const numTodosCompleted = todosStore.todos.filter(x => x.completed).length;
    return {
        allTodosCompleted: numTodosCompleted > 0 && numTodosCompleted === numTodos,
        todos: todosStore.todos.filter(todo => includeTodoBasedOnFilter(todo, filter)),
        numTodosActive: numTodos - numTodosCompleted,
        newTodoTitle: ''
That being said, I would prefer see the view component filter the todos, because different components might display them differently. I am sure that could be debated. I am just trying to make the case for functional components as opposed to templates.
In any case, I believe that sample demonstrates well the separation between model the view/model and the interface to the view components.
Edward Mulraney
Jun 17 2016 14:50
yeah this is the current general practice - you have the app state/store, then you create a view-specific model from pieces of the state. in redux they're called selectors
Jean-Jacques Dubray
Jun 17 2016 17:15
@edmulraney then the next question is what value observables bring to the table?
Edward Mulraney
Jun 17 2016 17:31
i suppose a convenient framework for reactive behaviour
ive not played with them properly yet
devin ivy
Jun 17 2016 17:32
observables versus what?
Jean-Jacques Dubray
Jun 17 2016 17:45
simple wiring, events, actions,...
devin ivy
Jun 17 2016 17:58
i guess you could say they bring "minimal computation" or performance to the table
and computation-order-agnositicism where applicable