These are chat archives for jdubray/sam

19th
Jul 2017
Fred Daoud
@foxdonut
Jul 19 2017 06:11
@formido I use a simple stream of model-update functions to produce a stream of models, and then I map it to calling ReactDOM.render.
Michael Terry
@formido
Jul 19 2017 17:44
I guess I don't get the point of streams yet at the very most basic level
If I have an update function, any event that needs to update the model can call that function and all those events will call it in a "stream"
what does the stream abstraction get me?
it makes it a queue so I can process them one at a time?
can I process events selectively and keep the unprocessed events in the stream for later?
This is after looking at meosis
Victor Noël
@victornoel
Jul 19 2017 17:50
@formido by "stream" do you also mean things like rxjs?
Michael Terry
@formido
Jul 19 2017 17:50
yes
I'm an erlang/elixir programmer, and in those languages the way to communicate between components is by sending messages that are stored in the "process mailbox" as a queued sequence
it's handy and if streams behave like that, I see the value
but the term stream in FRP sounds by default ephemeral, which doesn't sound nearly as handy
Victor Noël
@victornoel
Jul 19 2017 17:52
it's not the same, even though it could look like it, but yes, you start to program by reacting to changes, so it is quite useful, in the UI world, with templating (as in angular) where the view subscribe to some streams and changes only when things that concerns them changes
(I mean it's not the same as actors and message boxes)
(even though if you look at akka, they implement streams with actors ; )
look for some introductions to reactive streams, there is usually good examples, both in the ui world and in the non-ui world
Michael Terry
@formido
Jul 19 2017 17:54
so its first value is decoupling senders and receivers
Victor Noël
@victornoel
Jul 19 2017 17:54
I guess, but it's more about changing the way you organise your application I think
Michael Terry
@formido
Jul 19 2017 17:55
I mean, you're talking about pub/sub up there
Victor Noël
@victornoel
Jul 19 2017 17:55
pubsub is something else, even though there are strong links between
Michael Terry
@formido
Jul 19 2017 17:56
Unfortunately I've read a few intros
Victor Noël
@victornoel
Jul 19 2017 17:56
I just typed "reactive stream introduction" on google, there is lot of examples, you should read some to better understand what it entails
ah ok ^^
Michael Terry
@formido
Jul 19 2017 17:56
and they didn't convince me at the very beginning that it was useful
which doesn't mean anything about its usefulness
just that I personally don't grasp the advantage yet
Victor Noël
@victornoel
Jul 19 2017 17:57
well, it's an architectural choice, there is cases where they make more sense than other I guess, maybe for the kind of application you have in mind, they are not interesting
there is one interesting point about streams: they abstract over time! usually, in a stream, you get the same requested information, but at different time, so with different data each time
it can be useful
this is where I think it starts to be different from actors for example
(even though actors are lower level in that case, so you can express the same things with them)
but with rx streams you get lots of nice operators to work on your data as well as trigger stuffs to happen when new data arrives..
or should I say a new version of the data arrives
I'm not clear :)
Michael Terry
@formido
Jul 19 2017 18:00
thanks for the discussion
Victor Noël
@victornoel
Jul 19 2017 18:00
:)
Michael Terry
@formido
Jul 19 2017 18:01
I think perhaps the apps next on my plate are not complex enough for me to need to understand streams
Jean-Jacques Dubray
@jdubray
Jul 19 2017 18:04
streams in RFP behave a bit (ok, it's a stretch of imagination) like closures. They hold our state like a closure would do it for a function.
which is not exactly how you would think of it naturally
Michael Terry
@formido
Jul 19 2017 18:05
the state being the sequence or also sequence + interim calculations
?
Jean-Jacques Dubray
@jdubray
Jul 19 2017 18:05
As @victornoel pointed out, this is a way to factor your code, so the "code" is outside the stream but the state is in the stream.
Michael Terry
@formido
Jul 19 2017 18:06
ah, of course, any calculations are just a transformation of the state of the stream
Jean-Jacques Dubray
@jdubray
Jul 19 2017 18:07
"F"RP
IMHO, it's more important to decouple wiring from programming model. I don't dispute that some problems can be better solved with RFP, but as a general programming model, that would not be my first choice.
So many more problems can be dealt with pub/sub
Slađan Ristić
@sladiri
Jul 19 2017 18:14
As far as I understand, Cerebral's state API allows for automatic rerender for interested components. It could very well be premature optimization for most use-cases. :) It is "mandatory" pub-sub.
So it is geared towards fine-grained re-renders.
Fred Daoud
@foxdonut
Jul 19 2017 21:26
@formido it's not required to use streams to implement the Meiosis pattern. You could for example write a simple observable such as in this example, or write a minimal update function, as in this other example.
Jean-Jacques Dubray
@jdubray
Jul 19 2017 21:34
Angular4.3 new and improved

HttpClient rewrite

A new generic mechanism to handle requests and responses using interceptors. To build an interceptor, you declare a class that implements the HttpInterceptor interface, then you chain it to the other interceptors responsible to handle the request or response.

boy oh boy, this new programming model is mind blowing. I am sure they went through years of introspection to come up with it

Jean-Jacques Dubray
@jdubray
Jul 19 2017 21:39
My point is that when you don't have a foundational programming model, then everything is possible. The reason why this came up is possibly because sometimes they see the need for "acceptors", so it's not illogical to think about this idea, but outside the context of an action/model that unifies the concept well beyond HttpClient (as in it clearly doesn't belong there in anyway shape or form), I can't imagine the amount of horrific code that will be built on this new and improved HttpClient
Michael Terry
@formido
Jul 19 2017 21:43
@foxdonut Cool, thanks.

The 80% use-case for async middleware is dispatching 2 actions in sequence: the synchronous “setup action” ™ and an asynchronous “follow-up action” ™.

That's how I handle "loading" spinners for instance, it's ludicrous to use ancillary state machines to manage fetching data