Appearance
Restaurant resolver 🔮 ​
The menu resolver exports both restaurantMachine (which is used by other libraries internally) and resolveRestaurant which is documented below.
Restaurant resolver ties together the following resolvers into a single finite state machine using the actor model.
Usage ​
js
import { useState, useEffect } from 'react';
import { resolveRestaurant } from '@fingermarkglobal/restaurant.resolver';
const useExampleHook = () => {
const [restaurantState, setRestaurantState] = useState();
useEffect(() => {
if (restaurantState) return;
// Returns function to send commands to the machine
const run = resolveRestaurant({
transition: machine => setRestaurantState(machine),
});
run({
event: 'EXTERNAL_TRANSITION_SUCCESS',
});
}, [restaurantState, setRestaurantState]);
};