Block a State Transition with a Guard

InstructorIsaac Mann

Share this video with your friends

Send Tweet

If a network call returns an empty list, that should be rendered differently than a list with elements in it. We’ll create two substates of the http success state (withData and withoutData) and choose which substate to transition to based on the http response using an automatic transition and a guard.

Jaime Leonardo Suncin Cruz
~ 5 years ago

In the video is missing when updates the implementation of hasData guard, because now is necessary to check the ctx not the event parameter cause the guard is not called by an event.

dave
~ 5 years ago

I seem to have to use guards:{ hasData: (ctx, event) =>{ console.log(event) return event.data && event.data.count > 0 } }

~ 4 years ago

You are right, the video misses the part about updating guard!