Socket
Book a DemoInstallSign in
Socket

mobx-to-jsonpatch

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-to-jsonpatch

Turn MobX mutations into JSONPatch instructions

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

mobx-to-jsonpatch

Watch a MobX observable and compile a JSON Patch document that represents the changes made to the observable.

Installation

NPM: npm install mobx-to-jsonpatch

CDN: https://unpkg.com/mobx-to-jsonpatch

Usage

import { observable } from 'mobx'
import { Observer } from 'mobx-to-jsonpatch'

const obj = observable( { name : 'my boring object' } )

// Create an Observer for whatever observable you want to watch.
const observer = new Observer( obj )

// Now you can just make changes to `obj`...
obj.name = 'my awesome object'

// ...and they will be reflected in the Patches object that the
// Observer is building...
console.log( 'PATCHES:', observer.patches.toJSON() )

PATCHES: [
  { op : "test", path : "name", value : "my boring object" },
  { op : "replace", path : "name", value : "my awesome object" },
]

Author

Copyright 2019 Jason Kohles - email@jasonkohles.com

Keywords

mobx

FAQs

Package last updated on 22 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.