Created
December 22, 2019 21:04
-
-
Save kyleshevlin/4b6f4913fea03976f32cf96545f5041b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const filterSubStates = filterName => ({ | |
initial: "disabled", | |
states: { | |
disabled: { | |
on: { [`ENABLE_${filterName}`]: "enabled" } | |
}, | |
enabled: { | |
initial: "asc", | |
on: { | |
[`DISABLE_${filterName}`]: "disabled" | |
}, | |
states: { | |
asc: { | |
on: { [`TOGGLE_SORT_ORDER_FOR_${filterName}`]: "desc" } | |
}, | |
desc: { | |
on: { [`TOGGLE_SORT_ORDER_FOR_${filterName}`]: "asc" } | |
} | |
} | |
} | |
} | |
}); | |
const filterMachine = Machine({ | |
id: "filter", | |
type: "parallel", | |
on: { | |
RESET: { | |
target: ["byEmail.disabled", "byId.disabled", "byName.disabled"] | |
} | |
}, | |
states: { | |
byEmail: { | |
...filterSubStates("EMAIL") | |
}, | |
byId: { | |
...filterSubStates("ID") | |
}, | |
byName: { | |
...filterSubStates("NAME") | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment