remos-immer
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

remos-immer

An Immer wrapper for Remos

Installation

NPM

npm i remos-immer --save

YARN

yarn add remos-immer

Usages

With remos-immer

import { create, inject } from "remos";
import { withImmer } from "remos-immer";

inject(withImmer());

const todoModel = create({
  todos: [],
  add(todo) {
    this.todos.push(todo);
  },
  remove(id) {
    const index = this.todos.findIndex((x) => x.id === id);
    this.todos.splice(index, 1);
  },
});

Without remos-immer

import { create, configure } from "remos";

const todoModel = create({
  todos: [],
  add(todo) {
    this.todos = [...this.todos, todo];
  },
  remove(id) {
    const index = this.todos.findIndex((x) => x.id === id);
    this.todos = [
      ...this.todos.slice(0, index),
      ...this.todos.slice(index + 1),
    ];
  },
});

Package Sidebar

Install

npm i remos-immer

Weekly Downloads

1

Version

0.3.0

License

ISC

Unpacked Size

6.63 kB

Total Files

7

Last publish

Collaborators

  • linq2js