Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nx-js/observer-util

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nx-js/observer-util - npm Package Compare versions

Comparing version 4.2.2 to 4.3.0-alpha.0

81

dist/cjs.es5.js

@@ -75,2 +75,46 @@ 'use strict';

var _extends = Object.assign || function (target) {
var arguments$1 = arguments;
for (var i = 1; i < arguments.length; i++) { var source = arguments$1[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
// default handlers are exposed in the public API
// to allow devs to augment them instead of overwriting them
// they are frozen as they can only be used but must not be overwritten
// devs should use the setHandlers function for that
var defaultHandlers = Object.freeze({
orderReactions: function orderReactions(reactions) {
return reactions;
},
runReaction: function runReaction(target, context, args) {
return Reflect.apply(target, context, args);
},
get: function get(target, key, receiver) {
return Reflect.get(target, key, receiver);
},
has: function has(target, key) {
return Reflect.has(target, key);
},
ownKeys: function ownKeys(target) {
return Reflect.ownKeys(target);
},
set: function set(target, key, value, receiver) {
return Reflect.set(target, key, value, receiver);
},
deleteProperty: function deleteProperty(target, key) {
return Reflect.deleteProperty(target, key);
}
});
var handlers = defaultHandlers;
// add the new handlers to the existing ones
function setHandlers(newHandlers) {
handlers = _extends({}, handlers, newHandlers);
}
// reset all handlers to the default ones
function clearHandlers() {
handlers = _extends({}, defaultHandlers);
}
// reactions can call each other and form a call stack

@@ -83,3 +127,3 @@ var reactionStack = [];

if (reaction.unobserved) {
return Reflect.apply(fn, context, args);
return handlers.runReaction(fn, context, args);
}

@@ -98,3 +142,3 @@

reactionStack.push(reaction);
return Reflect.apply(fn, context, args);
return handlers.runReaction(fn, context, args);
} finally {

@@ -119,3 +163,3 @@ // always remove the currently running flag from the reaction when it stops execution

// iterate and queue every reaction, which is triggered by obj.key mutation
getReactionsForOperation(operation).forEach(queueReaction, operation);
handlers.orderReactions(getReactionsForOperation(operation)).forEach(queueReaction, operation);
}

@@ -342,4 +386,5 @@

var globalObj =
// eslint-disable-next-line
var globalObj = typeof window === 'object' ? window : Function('return this')();
typeof window === "object" ? window : Function("return this")();

@@ -350,3 +395,3 @@ // built-in object can not be wrapped by Proxies

// which switch the proxy to the raw object and to add reactive wiring
var handlers = new Map([[Map, collectionHandlers], [Set, collectionHandlers], [WeakMap, collectionHandlers], [WeakSet, collectionHandlers], [Object, false], [Array, false], [Int8Array, false], [Uint8Array, false], [Uint8ClampedArray, false], [Int16Array, false], [Uint16Array, false], [Int32Array, false], [Uint32Array, false], [Float32Array, false], [Float64Array, false]]);
var handlers$1 = new Map([[Map, collectionHandlers], [Set, collectionHandlers], [WeakMap, collectionHandlers], [WeakSet, collectionHandlers], [Object, false], [Array, false], [Int8Array, false], [Uint8Array, false], [Uint8ClampedArray, false], [Int16Array, false], [Uint16Array, false], [Int32Array, false], [Uint32Array, false], [Float32Array, false], [Float64Array, false]]);

@@ -357,9 +402,13 @@ function shouldInstrument(ref) {

var isBuiltIn = typeof constructor === 'function' && constructor.name in globalObj && globalObj[constructor.name] === constructor;
return !isBuiltIn || handlers.has(constructor);
return !isBuiltIn || handlers$1.has(constructor);
}
function getHandlers(obj) {
return handlers.get(obj.constructor);
return handlers$1.get(obj.constructor);
}
var _extends$1 = Object.assign || function (target) {
var arguments$1 = arguments;
for (var i = 1; i < arguments.length; i++) { var source = arguments$1[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;

@@ -370,3 +419,3 @@ var wellKnownSymbols = new Set(Object.getOwnPropertyNames(Symbol).map(function (key) { return Symbol[key]; }).filter(function (value) { return typeof value === 'symbol'; }));

function get(target, key, receiver) {
var result = Reflect.get(target, key, receiver);
var result = handlers.get(target, key, receiver);
// do not register (observable.prop -> reaction) pairs for well known symbols

@@ -398,3 +447,3 @@ // these symbols are frequently retrieved in low level JavaScript under the hood

function has(target, key) {
var result = Reflect.has(target, key);
var result = handlers.has(target, key);
// register and save (observable.prop -> runningReaction)

@@ -407,3 +456,3 @@ registerRunningReactionForOperation({ target: target, key: key, type: 'has' });

registerRunningReactionForOperation({ target: target, type: 'iterate' });
return Reflect.ownKeys(target);
return handlers.ownKeys(target);
}

@@ -422,3 +471,3 @@

// execute the set operation before running any reaction
var result = Reflect.set(target, key, value, receiver);
var result = handlers.set(target, key, value, receiver);
// do not queue reactions if the target of the operation is not the raw receiver

@@ -450,3 +499,3 @@ // (possible because of prototypal inheritance)

// execute the delete operation before running any reaction
var result = Reflect.deleteProperty(target, key);
var result = handlers.deleteProperty(target, key);
// only queue reactions for delete operations which resulted in an actual change

@@ -459,3 +508,6 @@ if (hadKey) {

var baseHandlers = { get: get, has: has, ownKeys: ownKeys, set: set, deleteProperty: deleteProperty };
// allow custom handlers for proxy traps that this lib does not use
// this prevents the need for double Proxy wrapping for users
// who wish to further extend JS behavior with Proxy traps
var baseHandlers = _extends$1({}, handlers, { get: get, has: has, ownKeys: ownKeys, set: set, deleteProperty: deleteProperty });

@@ -499,1 +551,4 @@ function observable(obj) {

exports.raw = raw;
exports.setHandlers = setHandlers;
exports.clearHandlers = clearHandlers;
exports.defaultHandlers = defaultHandlers;

@@ -67,2 +67,44 @@ 'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
// default handlers are exposed in the public API
// to allow devs to augment them instead of overwriting them
// they are frozen as they can only be used but must not be overwritten
// devs should use the setHandlers function for that
const defaultHandlers = Object.freeze({
orderReactions(reactions) {
return reactions;
},
runReaction(target, context, args) {
return Reflect.apply(target, context, args);
},
get(target, key, receiver) {
return Reflect.get(target, key, receiver);
},
has(target, key) {
return Reflect.has(target, key);
},
ownKeys(target) {
return Reflect.ownKeys(target);
},
set(target, key, value, receiver) {
return Reflect.set(target, key, value, receiver);
},
deleteProperty(target, key) {
return Reflect.deleteProperty(target, key);
}
});
let handlers = defaultHandlers;
// add the new handlers to the existing ones
function setHandlers(newHandlers) {
handlers = _extends({}, handlers, newHandlers);
}
// reset all handlers to the default ones
function clearHandlers() {
handlers = _extends({}, defaultHandlers);
}
// reactions can call each other and form a call stack

@@ -75,3 +117,3 @@ const reactionStack = [];

if (reaction.unobserved) {
return Reflect.apply(fn, context, args);
return handlers.runReaction(fn, context, args);
}

@@ -90,3 +132,3 @@

reactionStack.push(reaction);
return Reflect.apply(fn, context, args);
return handlers.runReaction(fn, context, args);
} finally {

@@ -111,3 +153,3 @@ // always remove the currently running flag from the reaction when it stops execution

// iterate and queue every reaction, which is triggered by obj.key mutation
getReactionsForOperation(operation).forEach(queueReaction, operation);
handlers.orderReactions(getReactionsForOperation(operation)).forEach(queueReaction, operation);
}

@@ -321,4 +363,5 @@

const globalObj =
// eslint-disable-next-line
const globalObj = typeof window === 'object' ? window : Function('return this')();
typeof window === "object" ? window : Function("return this")();

@@ -329,13 +372,15 @@ // built-in object can not be wrapped by Proxies

// which switch the proxy to the raw object and to add reactive wiring
const handlers = new Map([[Map, collectionHandlers], [Set, collectionHandlers], [WeakMap, collectionHandlers], [WeakSet, collectionHandlers], [Object, false], [Array, false], [Int8Array, false], [Uint8Array, false], [Uint8ClampedArray, false], [Int16Array, false], [Uint16Array, false], [Int32Array, false], [Uint32Array, false], [Float32Array, false], [Float64Array, false]]);
const handlers$1 = new Map([[Map, collectionHandlers], [Set, collectionHandlers], [WeakMap, collectionHandlers], [WeakSet, collectionHandlers], [Object, false], [Array, false], [Int8Array, false], [Uint8Array, false], [Uint8ClampedArray, false], [Int16Array, false], [Uint16Array, false], [Int32Array, false], [Uint32Array, false], [Float32Array, false], [Float64Array, false]]);
function shouldInstrument({ constructor }) {
const isBuiltIn = typeof constructor === 'function' && constructor.name in globalObj && globalObj[constructor.name] === constructor;
return !isBuiltIn || handlers.has(constructor);
return !isBuiltIn || handlers$1.has(constructor);
}
function getHandlers(obj) {
return handlers.get(obj.constructor);
return handlers$1.get(obj.constructor);
}
var _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;

@@ -346,3 +391,3 @@ const wellKnownSymbols = new Set(Object.getOwnPropertyNames(Symbol).map(key => Symbol[key]).filter(value => typeof value === 'symbol'));

function get(target, key, receiver) {
const result = Reflect.get(target, key, receiver);
const result = handlers.get(target, key, receiver);
// do not register (observable.prop -> reaction) pairs for well known symbols

@@ -374,3 +419,3 @@ // these symbols are frequently retrieved in low level JavaScript under the hood

function has(target, key) {
const result = Reflect.has(target, key);
const result = handlers.has(target, key);
// register and save (observable.prop -> runningReaction)

@@ -383,3 +428,3 @@ registerRunningReactionForOperation({ target, key, type: 'has' });

registerRunningReactionForOperation({ target, type: 'iterate' });
return Reflect.ownKeys(target);
return handlers.ownKeys(target);
}

@@ -398,3 +443,3 @@

// execute the set operation before running any reaction
const result = Reflect.set(target, key, value, receiver);
const result = handlers.set(target, key, value, receiver);
// do not queue reactions if the target of the operation is not the raw receiver

@@ -426,3 +471,3 @@ // (possible because of prototypal inheritance)

// execute the delete operation before running any reaction
const result = Reflect.deleteProperty(target, key);
const result = handlers.deleteProperty(target, key);
// only queue reactions for delete operations which resulted in an actual change

@@ -435,3 +480,6 @@ if (hadKey) {

var baseHandlers = { get, has, ownKeys, set, deleteProperty };
// allow custom handlers for proxy traps that this lib does not use
// this prevents the need for double Proxy wrapping for users
// who wish to further extend JS behavior with Proxy traps
var baseHandlers = _extends$1({}, handlers, { get, has, ownKeys, set, deleteProperty });

@@ -473,1 +521,4 @@ function observable(obj = {}) {

exports.raw = raw;
exports.setHandlers = setHandlers;
exports.clearHandlers = clearHandlers;
exports.defaultHandlers = defaultHandlers;

@@ -71,2 +71,46 @@ var connectionStore = new WeakMap();

var _extends = Object.assign || function (target) {
var arguments$1 = arguments;
for (var i = 1; i < arguments.length; i++) { var source = arguments$1[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
// default handlers are exposed in the public API
// to allow devs to augment them instead of overwriting them
// they are frozen as they can only be used but must not be overwritten
// devs should use the setHandlers function for that
var defaultHandlers = Object.freeze({
orderReactions: function orderReactions(reactions) {
return reactions;
},
runReaction: function runReaction(target, context, args) {
return Reflect.apply(target, context, args);
},
get: function get(target, key, receiver) {
return Reflect.get(target, key, receiver);
},
has: function has(target, key) {
return Reflect.has(target, key);
},
ownKeys: function ownKeys(target) {
return Reflect.ownKeys(target);
},
set: function set(target, key, value, receiver) {
return Reflect.set(target, key, value, receiver);
},
deleteProperty: function deleteProperty(target, key) {
return Reflect.deleteProperty(target, key);
}
});
var handlers = defaultHandlers;
// add the new handlers to the existing ones
function setHandlers(newHandlers) {
handlers = _extends({}, handlers, newHandlers);
}
// reset all handlers to the default ones
function clearHandlers() {
handlers = _extends({}, defaultHandlers);
}
// reactions can call each other and form a call stack

@@ -79,3 +123,3 @@ var reactionStack = [];

if (reaction.unobserved) {
return Reflect.apply(fn, context, args);
return handlers.runReaction(fn, context, args);
}

@@ -94,3 +138,3 @@

reactionStack.push(reaction);
return Reflect.apply(fn, context, args);
return handlers.runReaction(fn, context, args);
} finally {

@@ -115,3 +159,3 @@ // always remove the currently running flag from the reaction when it stops execution

// iterate and queue every reaction, which is triggered by obj.key mutation
getReactionsForOperation(operation).forEach(queueReaction, operation);
handlers.orderReactions(getReactionsForOperation(operation)).forEach(queueReaction, operation);
}

@@ -338,4 +382,5 @@

var globalObj =
// eslint-disable-next-line
var globalObj = typeof window === 'object' ? window : Function('return this')();
typeof window === "object" ? window : Function("return this")();

@@ -346,3 +391,3 @@ // built-in object can not be wrapped by Proxies

// which switch the proxy to the raw object and to add reactive wiring
var handlers = new Map([[Map, collectionHandlers], [Set, collectionHandlers], [WeakMap, collectionHandlers], [WeakSet, collectionHandlers], [Object, false], [Array, false], [Int8Array, false], [Uint8Array, false], [Uint8ClampedArray, false], [Int16Array, false], [Uint16Array, false], [Int32Array, false], [Uint32Array, false], [Float32Array, false], [Float64Array, false]]);
var handlers$1 = new Map([[Map, collectionHandlers], [Set, collectionHandlers], [WeakMap, collectionHandlers], [WeakSet, collectionHandlers], [Object, false], [Array, false], [Int8Array, false], [Uint8Array, false], [Uint8ClampedArray, false], [Int16Array, false], [Uint16Array, false], [Int32Array, false], [Uint32Array, false], [Float32Array, false], [Float64Array, false]]);

@@ -353,9 +398,13 @@ function shouldInstrument(ref) {

var isBuiltIn = typeof constructor === 'function' && constructor.name in globalObj && globalObj[constructor.name] === constructor;
return !isBuiltIn || handlers.has(constructor);
return !isBuiltIn || handlers$1.has(constructor);
}
function getHandlers(obj) {
return handlers.get(obj.constructor);
return handlers$1.get(obj.constructor);
}
var _extends$1 = Object.assign || function (target) {
var arguments$1 = arguments;
for (var i = 1; i < arguments.length; i++) { var source = arguments$1[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;

@@ -366,3 +415,3 @@ var wellKnownSymbols = new Set(Object.getOwnPropertyNames(Symbol).map(function (key) { return Symbol[key]; }).filter(function (value) { return typeof value === 'symbol'; }));

function get(target, key, receiver) {
var result = Reflect.get(target, key, receiver);
var result = handlers.get(target, key, receiver);
// do not register (observable.prop -> reaction) pairs for well known symbols

@@ -394,3 +443,3 @@ // these symbols are frequently retrieved in low level JavaScript under the hood

function has(target, key) {
var result = Reflect.has(target, key);
var result = handlers.has(target, key);
// register and save (observable.prop -> runningReaction)

@@ -403,3 +452,3 @@ registerRunningReactionForOperation({ target: target, key: key, type: 'has' });

registerRunningReactionForOperation({ target: target, type: 'iterate' });
return Reflect.ownKeys(target);
return handlers.ownKeys(target);
}

@@ -418,3 +467,3 @@

// execute the set operation before running any reaction
var result = Reflect.set(target, key, value, receiver);
var result = handlers.set(target, key, value, receiver);
// do not queue reactions if the target of the operation is not the raw receiver

@@ -446,3 +495,3 @@ // (possible because of prototypal inheritance)

// execute the delete operation before running any reaction
var result = Reflect.deleteProperty(target, key);
var result = handlers.deleteProperty(target, key);
// only queue reactions for delete operations which resulted in an actual change

@@ -455,3 +504,6 @@ if (hadKey) {

var baseHandlers = { get: get, has: has, ownKeys: ownKeys, set: set, deleteProperty: deleteProperty };
// allow custom handlers for proxy traps that this lib does not use
// this prevents the need for double Proxy wrapping for users
// who wish to further extend JS behavior with Proxy traps
var baseHandlers = _extends$1({}, handlers, { get: get, has: has, ownKeys: ownKeys, set: set, deleteProperty: deleteProperty });

@@ -490,2 +542,2 @@ function observable(obj) {

export { observe, unobserve, observable, isObservable, raw };
export { observe, unobserve, observable, isObservable, raw, setHandlers, clearHandlers, defaultHandlers };

@@ -63,2 +63,44 @@ const connectionStore = new WeakMap();

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
// default handlers are exposed in the public API
// to allow devs to augment them instead of overwriting them
// they are frozen as they can only be used but must not be overwritten
// devs should use the setHandlers function for that
const defaultHandlers = Object.freeze({
orderReactions(reactions) {
return reactions;
},
runReaction(target, context, args) {
return Reflect.apply(target, context, args);
},
get(target, key, receiver) {
return Reflect.get(target, key, receiver);
},
has(target, key) {
return Reflect.has(target, key);
},
ownKeys(target) {
return Reflect.ownKeys(target);
},
set(target, key, value, receiver) {
return Reflect.set(target, key, value, receiver);
},
deleteProperty(target, key) {
return Reflect.deleteProperty(target, key);
}
});
let handlers = defaultHandlers;
// add the new handlers to the existing ones
function setHandlers(newHandlers) {
handlers = _extends({}, handlers, newHandlers);
}
// reset all handlers to the default ones
function clearHandlers() {
handlers = _extends({}, defaultHandlers);
}
// reactions can call each other and form a call stack

@@ -71,3 +113,3 @@ const reactionStack = [];

if (reaction.unobserved) {
return Reflect.apply(fn, context, args);
return handlers.runReaction(fn, context, args);
}

@@ -86,3 +128,3 @@

reactionStack.push(reaction);
return Reflect.apply(fn, context, args);
return handlers.runReaction(fn, context, args);
} finally {

@@ -107,3 +149,3 @@ // always remove the currently running flag from the reaction when it stops execution

// iterate and queue every reaction, which is triggered by obj.key mutation
getReactionsForOperation(operation).forEach(queueReaction, operation);
handlers.orderReactions(getReactionsForOperation(operation)).forEach(queueReaction, operation);
}

@@ -317,4 +359,5 @@

const globalObj =
// eslint-disable-next-line
const globalObj = typeof window === 'object' ? window : Function('return this')();
typeof window === "object" ? window : Function("return this")();

@@ -325,13 +368,15 @@ // built-in object can not be wrapped by Proxies

// which switch the proxy to the raw object and to add reactive wiring
const handlers = new Map([[Map, collectionHandlers], [Set, collectionHandlers], [WeakMap, collectionHandlers], [WeakSet, collectionHandlers], [Object, false], [Array, false], [Int8Array, false], [Uint8Array, false], [Uint8ClampedArray, false], [Int16Array, false], [Uint16Array, false], [Int32Array, false], [Uint32Array, false], [Float32Array, false], [Float64Array, false]]);
const handlers$1 = new Map([[Map, collectionHandlers], [Set, collectionHandlers], [WeakMap, collectionHandlers], [WeakSet, collectionHandlers], [Object, false], [Array, false], [Int8Array, false], [Uint8Array, false], [Uint8ClampedArray, false], [Int16Array, false], [Uint16Array, false], [Int32Array, false], [Uint32Array, false], [Float32Array, false], [Float64Array, false]]);
function shouldInstrument({ constructor }) {
const isBuiltIn = typeof constructor === 'function' && constructor.name in globalObj && globalObj[constructor.name] === constructor;
return !isBuiltIn || handlers.has(constructor);
return !isBuiltIn || handlers$1.has(constructor);
}
function getHandlers(obj) {
return handlers.get(obj.constructor);
return handlers$1.get(obj.constructor);
}
var _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;

@@ -342,3 +387,3 @@ const wellKnownSymbols = new Set(Object.getOwnPropertyNames(Symbol).map(key => Symbol[key]).filter(value => typeof value === 'symbol'));

function get(target, key, receiver) {
const result = Reflect.get(target, key, receiver);
const result = handlers.get(target, key, receiver);
// do not register (observable.prop -> reaction) pairs for well known symbols

@@ -370,3 +415,3 @@ // these symbols are frequently retrieved in low level JavaScript under the hood

function has(target, key) {
const result = Reflect.has(target, key);
const result = handlers.has(target, key);
// register and save (observable.prop -> runningReaction)

@@ -379,3 +424,3 @@ registerRunningReactionForOperation({ target, key, type: 'has' });

registerRunningReactionForOperation({ target, type: 'iterate' });
return Reflect.ownKeys(target);
return handlers.ownKeys(target);
}

@@ -394,3 +439,3 @@

// execute the set operation before running any reaction
const result = Reflect.set(target, key, value, receiver);
const result = handlers.set(target, key, value, receiver);
// do not queue reactions if the target of the operation is not the raw receiver

@@ -422,3 +467,3 @@ // (possible because of prototypal inheritance)

// execute the delete operation before running any reaction
const result = Reflect.deleteProperty(target, key);
const result = handlers.deleteProperty(target, key);
// only queue reactions for delete operations which resulted in an actual change

@@ -431,3 +476,6 @@ if (hadKey) {

var baseHandlers = { get, has, ownKeys, set, deleteProperty };
// allow custom handlers for proxy traps that this lib does not use
// this prevents the need for double Proxy wrapping for users
// who wish to further extend JS behavior with Proxy traps
var baseHandlers = _extends$1({}, handlers, { get, has, ownKeys, set, deleteProperty });

@@ -464,2 +512,2 @@ function observable(obj = {}) {

export { observe, unobserve, observable, isObservable, raw };
export { observe, unobserve, observable, isObservable, raw, setHandlers, clearHandlers, defaultHandlers };

2

package.json
{
"name": "@nx-js/observer-util",
"version": "4.2.2",
"version": "4.3.0-alpha.0",
"description": "Simple transparent reactivity with 100% language coverage. Made with ES6 Proxies.",

@@ -5,0 +5,0 @@ "main": "dist/cjs.es5.js",

@@ -47,2 +47,3 @@ # The Observer Utility

* [React Easy State](https://github.com/solkimicreb/react-easy-state) is a state management solution for React with a minimal learning curve.
* [preact-ns-observer](https://github.com/mseddon/preact-nx-observer) provides a simple `@observable` decorator that makes Preact components reactive.

@@ -105,2 +106,15 @@ ## Installation

#### Preact Component
```js
import { observer } from "preact-nx-observer";
let store = observable({ title: "This is foo's data"});
@observer // Component will now re-render whenever store.title changes.
class Foo extends Component {
render() {
return <h1>{store.title}</h1>
}
}
```
#### More examples

@@ -144,3 +158,3 @@

<details>
<summary>Computed properties</summary>
<summary>Getter properties</summary>

@@ -154,3 +168,3 @@ ```js

get name() {
return `${firstName} ${lastName}`;
return `${this.firstName} ${this.lastName}`;
}

@@ -157,0 +171,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc