These are chat archives for jdubray/sam

29th
Oct 2017
Jean-Jacques Dubray
@jdubray
Oct 29 2017 06:35
@pfurini stenciljs is using workbox, I'll have to investigate that first: https://workboxjs.org/
Paolo Furini
@pfurini
Oct 29 2017 07:36
It seems well documented, I can't speak of quality as I never used it before.. but given that they are going to use the produced components in ionic, they must have considered several factors before deciding on a library, first of all cross browser compatibility and performance
Jean-Jacques Dubray
@jdubray
Oct 29 2017 07:39
So far my experience on Service Workers is that it's still bleeding edge for handling cross-origin requests, I am hoping they can make it a bit more accessible to the mere mortals.
Otherwise I'd use SW anytime over things like React Native or Cordova.
Paolo Furini
@pfurini
Oct 29 2017 07:42
Yeah they are still in early days.. but support is becoming more and more mainstream, I hope they'll reach maturity soon
Jean-Jacques Dubray
@jdubray
Oct 29 2017 07:46
me too, this is a really important technology, with support from Chrome and Mozilla, Edge and Safari would go further into irrelevancy if they don't support it. I am just puzzled as to why it is so hard/flaky to add a proxy to a browser.
Paolo Furini
@pfurini
Oct 29 2017 07:55
Apple just agreed to add full support for service workers in safari, they'll come in next version. Microsoft announced they'll support even as installed apps in a native window (much like an electron shell provided by the SO)
Jean-Jacques Dubray
@jdubray
Oct 29 2017 08:01
:+1:
Jean-Jacques Dubray
@jdubray
Oct 29 2017 09:06
Well workbox works! I can tunnel through the service-worker.
https://workboxjs.org/examples/workbox-routing/index.html
Paolo Furini
@pfurini
Oct 29 2017 09:16
Well that's great! But service workers are not mandatory for stencil components, isn't it?
Jean-Jacques Dubray
@jdubray
Oct 29 2017 09:18
Not sure, perhaps that's just required when you don't want to use a native shell.
Paolo Furini
@pfurini
Oct 29 2017 09:18
I mean, I'd like to leverage stencil for compiling some ready-made components, and integrate them seamlessly in other stacks, but I need to target every browser
Jean-Jacques Dubray
@jdubray
Oct 29 2017 09:19
yes, understood
Paolo Furini
@pfurini
Oct 29 2017 09:23
From the docs: Stencil uses a dynamic loader to load the custom elements polyfill only on browsers that need it. With this polyfill Stencil's browser support is Chrome (and all chrome based browsers), Safari, Firefox, Edge, and IE11.
but these polyfills include service worker support? It's not so clear
Paolo Furini
@pfurini
Oct 29 2017 09:30
Well, can't find anything in the polyfills for service workers (and I don't know of a full SW polyfill out there), so I can't find a connection between the list of supported browsers, and the usage of service workers in a stencil component...
I can't investigate more now, I'll let you solve this "mystery" if you'd like.. ;)
probably if you (component dev) decide to use SW in your component, you'll simply lose broader compatibility
Jean-Jacques Dubray
@jdubray
Oct 29 2017 11:32
I find the combination PWA / SW/ PouchDB or GunDB amazing
Paolo Furini
@pfurini
Oct 29 2017 12:28
Yes that's the direction ionic team is going.. I like native script, react native and the likes, but TBH ionic gives me the best from the web world with PWAs support and Cordova when I need it
Most of the time I need a platform to deliver low cost app solutions, both as MVPs or first versions to go quickly on the stores (better get real feedback as quickly as possible)
Jean-Jacques Dubray
@jdubray
Oct 29 2017 12:46
Even for native apps the concept of service worker (proxy) would be a nice addition. When you look at workbox, there are so many strategies that native apps simply don't support (not to mention the annoyence of having to update your apps periodically).
Holger Winkelmann
@hwinkel
Oct 29 2017 13:03
hi, just read you InfoQ Artikel
Jean-Jacques Dubray
@jdubray
Oct 29 2017 13:04
@hwinkel hi, welcome. Thank you.
Holger Winkelmann
@hwinkel
Oct 29 2017 13:05
We are just reworking our Frontend Strategy and beeing a Functional Programming shop (Elixir, Erlang and somd Elm tests) your Pattern looks like a good fit for the team
also I want to put the Server in the Driver Seat for Frontend State
Jean-Jacques Dubray
@jdubray
Oct 29 2017 13:07
yes, it's a simple factoring which can be used in functional reactive frameworks such as Elm. It provides a simple, yet robust structure to event handlers
One of the key benefits is that actions, model and/or state can run wherever it makes the most sense
You could even wire 3rd party actions with OAuth tokens
Frameworks like Elm or Redux advocate using pure functions/immutability to structure event handlers, IMHO, that's not optimal. Hence SAM.
Holger Winkelmann
@hwinkel
Oct 29 2017 13:11
Yes, in our Elixr / Phoenix World a Library just comes up which allows to call JS functions in the browser from the server via channels (a websocket abstraction) which should allow to distribute the SAM pattern between client an server a like
Jean-Jacques Dubray
@jdubray
Oct 29 2017 13:11
SAM can also be used everywhere you need to manage state, for instance, API orchestration.
Yes, SAM is just a programming model, it does not assume any particular wiring or architecture. It can use any.
Jean-Jacques Dubray
@jdubray
Oct 29 2017 13:15
I see, SAM is very flexible when it comes to managing the State Representation since one of it other key value is a State Representation distinct form the View. So you could generate the State Representation on the server and render it in the browser. You are not forced to do anything related to the DOM on the server.
Holger Winkelmann
@hwinkel
Oct 29 2017 13:17
I'm not sure but I also think with the SAM model it's also easier to construct SPA Apps which react on server changes. I.e. due Auth changes or pushing a Client UI to the right State, i.e. to force the user to given UI interaction like filling out additional Form. Currently managing this is SPA Apps. is hart for us as it is a interpretation of the Sate of some REST resources like "if you see this and this but missing that please render a UI state"
Jean-Jacques Dubray
@jdubray
Oct 29 2017 13:18
Absolutely, SAM does not make any assumption on the origin of a proposal. As long as you have a way to present a proposal to the model, it does not matter which action was responsbile or how it was triggered.
This "feature" can also be used to implement smart action sequencing strategies, such as SAM-SAFE: https://www.npmjs.com/package/sam-safe
which supports a generic cancellation mechanism
(for long running actions)
SAM has one of the most robust formalism behind it: TLA+ https://dzone.com/articles/the-three-approximations-you-should-never-use-when
Holger Winkelmann
@hwinkel
Oct 29 2017 13:29
I was never aware there was a formal pattern behind the ideas we have
Jean-Jacques Dubray
@jdubray
Oct 29 2017 13:35
TLA+ is really worth knowing about, as I see, it is (at) the foundation of Computer Science. Sure we can describe computation in many different ways, but so far, this seems to be the most general known thus far.
Holger Winkelmann
@hwinkel
Oct 29 2017 13:36
@jdubray even you say, don't use angular or react I would like to use pre made components build around these technologies. i.e. https://vmware.github.io/clarity/documentation/datagrid/structure
Jean-Jacques Dubray
@jdubray
Oct 29 2017 13:37
You can use similar JQuery components, SAM works well with JQuery (without the DOM manipulations)
You don't have to listen to me, I am just allergic to Frameworks.
Holger Winkelmann
@hwinkel
Oct 29 2017 13:38
or you need to interact on the JS api level, and let the angular data fetching alone
Jean-Jacques Dubray
@jdubray
Oct 29 2017 13:38
I just want to point out that Frameworks have always failed people who used them.
I did some big projects with Angular and it works well.
I just feel that it takes 50% more time/code when using a framework. Angular's programming model is flexible, but it is verbose/bloated and you have to deal with a separate template language.
Worse, I don't know if that changed but in 2016 it took us weeks to find a date picker that worked.
Holger Winkelmann
@hwinkel
Oct 29 2017 13:40
and this angular components might not force you to REST CRUD directly and therefore SAM should be applicable
Jean-Jacques Dubray
@jdubray
Oct 29 2017 13:41
yes, aboslutely
Once I get going going, coding with Angular is relatively pleasant, precisely because the programming model is rather flexible. React appears more rigid to me.
Holger Winkelmann
@hwinkel
Oct 29 2017 13:44
what we like on clarity are the consistent UI elements focused on "admin apps" rather then combining independent jquery components. this might be different on EndUser Centric Web Apps.
Jean-Jacques Dubray
@jdubray
Oct 29 2017 13:46
You can achieve the same thing with SAM. I implement my projects with a "theme" that can be changed at any time. The theme is made up of pure functions (View components) that are driven by the State function's State Representation (props).
For instance that's an ES6 starter project: https://github.com/jdubray/startbootstrap-clean-blog
All view components are in theme.js
The Actions and Model Acceptors can also be componentized easily. (https://github.com/jdubray/startbootstrap-clean-blog/blob/master/components/post.component.js)
Paolo Furini
@pfurini
Oct 29 2017 14:23
Because I DON'T want to deal with ngrx/store.. quoting from that article "We built a 50-line service that integrates with NgRx effects and gets rid of a lot of race conditions seen in a typical web application." Typical?? Yes, if you end up using redux style state management, maybe they're "typical" 😓
Jean-Jacques Dubray
@jdubray
Oct 29 2017 14:29
ah ah... when you cobble together action/model/state in a single so called "pure" function, you would magnify these problems, especially when you account for API calls.
because, that's what is a reducer, action/model/state code conveniently written together in any order you want, then for API calls, you just hope for the best, while keeping track of everything that is in flight. But what do I know?