These are chat archives for jdubray/sam

13th
Apr 2018
Jean-Jacques Dubray
@jdubray
Apr 13 2018 00:46
No matter how big and wealthy the company, cost and (internal) developers' interest amounts to gravitational forces.
I like yarn better than npm. I am surprised the npm client is still so far behind.
devin ivy
@devinivy
Apr 13 2018 12:39
random question! on the topic of proposing mutations, have you ever played with dispatching the mutation in the form of a function @jdubray ? the model would be in charge of simulating the mutation by applying the function, then checking if it's valid.
Jean-Jacques Dubray
@jdubray
Apr 13 2018 20:21
I think it's totally ok. It's not so much about controlling the mutation, it's rather about controlling when it happens (including synchronization). From what I understand that's the fondation of temporal programming. The key is to always be in the position to reason about the temporality of your code.
Fred Daoud
@foxdonut
Apr 13 2018 20:26
what are use cases for rejecting proposals?
devin ivy
@devinivy
Apr 13 2018 20:32
so that the action caller doesn't have to know whether what they're trying to do is allowed.
Fred Daoud
@foxdonut
Apr 13 2018 20:36
right, but wondering about practical examples/use cases where you would reject a proposal.
devin ivy
@devinivy
Apr 13 2018 20:39
suppose you have a form to edit some data object that exists in your database. as the user types they may pass through some invalid values that you wouldn't want to reflect in application state, but would want to take the valid values. this happens especially when you type numbers: - -1 -1. -1.5
or imagine if in your rocket launch examples there were more complex business rules around when you're allowed to decrement or abort.
Fred Daoud
@foxdonut
Apr 13 2018 20:42
for the first one I'd just have what the user is typing in a separate property of the state. then when they hit "save" the validation would run. validation failures would be shown in the UI. data wouldn't be sent at all until validation passes.
I guess the part of the code that runs the validation is somewhat considered as accepting/rejecting a proposal
but really it's just the state changing in different ways (validation errors vs save success)
devin ivy
@devinivy
Apr 13 2018 20:43
i once had to "live-update" a webgl view of my data as a user typed new values.
the values were on database records that were save-able, but i had to reflect their current values immediately.
so there was some duplication of business rules in the front- and back-end to know if the user typed a valid value before they officially saved it. sort of an optimistic view of the database.
in that case i approached it by implementing the business rules in the reducer and rejecting some actions if they lead to invalid values
Fred Daoud
@foxdonut
Apr 13 2018 20:45
cool
devin ivy
@devinivy
Apr 13 2018 20:45
just an example! i think there are different ways to do it too—what you said would definitely work in tons of scenarios.
Fred Daoud
@foxdonut
Apr 13 2018 20:46
sounds reasonable, thanks Devin! :100:
devin ivy
@devinivy
Apr 13 2018 20:47
cheers!
Fred Daoud
@foxdonut
Apr 13 2018 20:47
Friday almost 5pm here, so :beers: :)
devin ivy
@devinivy
Apr 13 2018 20:48
same ;)