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

destination path

PreviousNo-Reducer ActionsNextcreate

Last updated 2 years ago

As we know, in Redux, the state is represented as a tree or a JSON object. At times, it becomes necessary to modify a nested object or a leaf in the tree. In order to achieve this, a destination path is provided, which points to the specific object that needs to be modified.

1. We will utilize the symbol > to indicate the specific object we intend to modify.

For example: we want to modify the name inside company inside the User. We have to write a path to go to that named object.

In this case, we use > symbol to point out

User>company>name 

In order to see how to use the Destination Path, we can examine an example of an insert function where we aim to insert an object into a leaf node of the tree.

Example of using Destination Path

dispatch(insert('User>address>geo', gps', {x,y,z}); 

2. If you want to traverse an item in an array, you can use the symbol | [key]=[value] to specify the particular object that you want to modify.

Update companies with cid=5 in students with id=4 in MyClass

dispatch(update('MyClass>students|id=4>companies', { name: "Meta" }, 5, 'cid'))

I want to { gps: {x,y,z} } into User>address>geo

πŸ“–
🎯
insert