These are chat archives for jdubray/sam

Jun 2016
Jun 15 2016 05:40
That would be awesome @jdubray
i really want to find a framework to try these things out
Edward Mulraney
Jun 15 2016 07:38
@jdubray "
I actually can't understand why people would think it is easier to manage subscriptions or explicit states versus allowed actions."
what's an example of a subscription vs an allowed action?
Jean-Jacques Dubray
Jun 15 2016 07:49
when you subscribe to an observable you have to then unsubscribe, this becomes quickly unwieldy, not even counting having to deal with hot/cold observables.
In SAM the output of the SAM function is the list of allowed actions in the next step (since SAM is inherently step based). So you are never subscribing to anything, any event can be triggered, you just need a piece of code that enforces the allowed actions when one is triggered. This is exactly what SAFE is doing, but that's rather trivial, you don't really need SAFE to do that.
With SAM you can then enforce the actions that can present data to the model, if a step has already been presented with data, any (belated) action which is trying to present data will be rejected.
Again, that's standard in SAFE. That's very powerful compared to managing a subscription and then when an allowed action has successfully proposed data, the model has to "unsubscribe" to all the other observables.
In SAM you only need to keep track of the state/status you are in and what are the allowed actions in that state.
Edward Mulraney
Jun 15 2016 08:01
what are you comparing SAFE to in this instance? what framework
Jean-Jacques Dubray
Jun 15 2016 08:06
Jean-Jacques Dubray
Jun 15 2016 14:29
I refactored the Angular 2 sample with a SAM service which wires the elements pattern, while using intents.
The implementation looks like this:
The index.html contains only a variable to mount the actions (not sure how I can invoke Angular methods from the generated components):
      var actionsMount = {} ;
      System.import('app').catch(function(err){ console.error(err); });

State, Actions, Model are written in TypeScript as well
The SAM service is injected in the AppComponent as a service provider:
  selector: 'my-app',
  providers: [SamService],
  template: '[Container]<br> <child id="container"></child> <br>[/Container]'