These are chat archives for jdubray/sam

4th
Mar 2018
Jean-Jacques Dubray
@jdubray
Mar 04 2018 02:19
@victornoel I don't know anything about ngrx/store. I don't have time right now to explore.
@pfurini I would not call Redux complex, it is rather naive, thinking that a pure functional approach without temporal logic constructs could be used to manage application state mutations
Jean-Jacques Dubray
@jdubray
Mar 04 2018 08:52
@pfurini wrt nap, render is a special next action. If you want to use the predicate correctly, you would return true if a (synchronous) next action was triggered, false otherwise. You would then render on false. The predicate can be used to decide whether we are ready to release the state to its consumer(s)
Nivani
@Nivani
Mar 04 2018 12:32
@victornoel This might be interesting for you: https://github.com/Nivani/todo-sam
Paolo Furini
@pfurini
Mar 04 2018 12:41
@Nivani seems very interesting, thanks for sharing.. I haven't looked through the code yet, but every practical example of angular + SAM is always welcome 👍
Victor Noël
@victornoel
Mar 04 2018 12:53
@jdubray now I understand that when you said "ngrx pub/sub" at the beginning on the discussion, you actually meant "rxjs pub/sub"...
thx @Nivani
Jean-Jacques Dubray
@jdubray
Mar 04 2018 15:58
@victornoel sorry, too many libraries.
Jean-Jacques Dubray
@jdubray
Mar 04 2018 16:12
@Nivani the differences with my implementation are notable:
1/ Every Angular component has a present method to encapsulate mutations. Actions like this are prohibited, you can present to the local SAM instance or the parent/root :
public stopEditing(todo: Todo, editedTitle: string) {
    todo.title = editedTitle;
    todo.editing = false;
  }
When your component is simple that does not make a bit difference, otherwise it does. It also allows you enter use the present method to process/present the parent state representation.
Jean-Jacques Dubray
@jdubray
Mar 04 2018 16:17
2/ Another big difference, services are innaccessible from any component (only actions and model)
constructor(private sam: NgSAM<Todos>, private todoService: TodoService) {
    todoService.getTodos().then(todos => this.presentTodos(todos));
  }
or
public remove(todo: Todo) {
    this.todoService.removeTodo(todo.id).then(todos => this.presentTodos(todos));
  }
One could argue that all actions are in the app.component, but I would recommend keeping your application logic separate from your component logic .
devin ivy
@devinivy
Mar 04 2018 23:28
wow! this is a rather huge endorsement. https://twitter.com/sebmarkbage/status/970404586224676864
i don't just mean of immer, but of mutability in the context of state management. also, hearing the word "temporal"...