{"repo":"nilsmehlhorn/ngrx-wieder","free":true,"listed":false,"github":"https://github.com/nilsmehlhorn/ngrx-wieder","clone":"git clone https://github.com/nilsmehlhorn/ngrx-wieder.git","description":"Lightweight undo-redo for Angular with NgRx & immer.js","language":"TypeScript","stars":127,"topics":["angular","ngrx","undo","redo"],"license":"MIT","category":"ui-components","readme_excerpt":"&nbsp; ngrx-wieder is a lightweight yet configurable solution for implementing undo-redo in Angular apps on top of NgRx. It's based on immer hence the name wieder (German for: again) ⚡ Example (Demo) Prerequisites Make sure you're using immer to update your NgRx (sub-)state. That means you're using mutating APIs to update the state while immer provides a new state behind the scenes. If you're just starting out, install immer with this command: Installation Install this library with the following command: Usage Firstly, extend the UndoRedoState with your custom state definition. This will prepare state properties for containing the undo-redo history. You can spread initialUndoRedoState into your initial state to initialze these properties: Then, you'll initialize ngrx-wieder and optionally pass a custom config. It'll return an object with the function createUndoRedoReducer which you can use just like createReducer from NgRx, however, state inside on will be a immer draft of the last state. If you'd rather not return the state in each on-reducer, you can use produceOn instead. Tip : Inside on or produceOn you can access the original state of an immer.js draft, therefore the last state, with the original function. Then whenever you'd like to undo or redo one of the passed allowedActionTypes simply dispatch the corresponding actions: Configuration Option Default Description :--------------------- :------------------------------ :---------------------------------------------------","default_branch":null,"files":null,"tree":[],"storefront":"/r/nilsmehlhorn","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/nilsmehlhorn/ngrx-wieder/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}