insert
Insert function is used to insert an object, an array, or data to a node in the reducer tree.
dispatch(insert('DESTINATION', 'OBJECT-NAME', PAYLOAD ));
There are 3 parameters: Destination: which could be a destination path or the name of the object you want to insert to. Object name: the name of the object Payload: the value of the object; it could be an object, array, or data.
Example 1:
We want to add an object { food: โcrawfishโ }
to the User object.
dispatch(insert('User', 'food', 'crawfish'));

Example 2:
Insert an array meal: ["crawfish", "corn", "hotdog", "shrimp"]
to the User
dispatch(insert('User', 'meal', ["crawfish", "corn", "hotdog", "shrimp"]));

Last updated