no-reducer
  • πŸš€Introduction
    • ☺️Demonstration
  • πŸ–₯️Installation
  • πŸ“–No-Reducer Actions
    • 🎯destination path
    • create
      • create an object/array
    • insert
      • insert to an array item
    • remove
      • remove with condition
      • remove without condition
    • replace
      • replace with condition
      • replace without condition
    • update
      • update with condition
    • append
    • clear
      • clear an array item
Powered by GitBook
On this page
  1. No-Reducer Actions

insert

Previouscreate an object/arrayNextinsert to an array item

Last updated 2 years ago

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 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"]));
πŸ“–
destination path