1. 2
    Define Discrete State Transitions using the State ADT
    3m 42s

Define Discrete State Transitions using the State ADT

Share this video with your friends

Send Tweet

We build our first state transactions as two discrete transactions, each working on a specific portion of the state. Each of these transitions are governed by an acceptable range and we want to be able to apply these limit within our model.

With our discrete transactions we see that is easy to reason about and keeps our rules local to the data being worked on, without having to be considered in other transitions or, even worse, in the eventual view layer. Patterns like this make it easier to easily transport a given data model to any view layer.

zarcode
~ 6 years ago

The over function works good on changing direct props of state object. Need help on how to change props of nested object inside of state?

Ian Hofmann-Hicksinstructor
~ 6 years ago

The over function works good on changing direct props of state object. Need help on how to change props of nested object inside of state?

It really all depends on your structure, without information about your domain it is hard to make a specific suggestion. But the beauty of over in this case is that it takes a function and will return the value at your specified key. If that value is an object then you can use mapProps, loaded with your change. Or you can use the ramda lens functions if you have a lot of nested data at a specific key.

The only real point of over is to merge your state transition at a specific scope, you can do whatever you need to do with the function you provide it.

zarcode
~ 6 years ago

Got it. Thank you! Love the course.

Jonathan Stiansen
~ 6 years ago

It looks like we should just be using reasonML for this... ;-) Loving this idea btw, going into my training for new employees.

Daniel Lopez
~ 5 years ago

Why, when you call a function without arguments, you say "calling with unit"?

Ian Hofmann-Hicksinstructor
~ 5 years ago

Why, when you call a function without arguments, you say "calling with unit"?

That is the Type, notice that it looks like an empty tuple (). That can be considered a singleton Set or a Set with one element in it, which is undefined