New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

observable-slice

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

observable-slice - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

6

dist/create.d.ts

@@ -8,3 +8,3 @@ /**

isEqual?: ((prev: any, next: any) => boolean) | undefined;
}>>({ initState, pubs, useSubs, notifyMiddleware, logger, }: {
}>>({ initState, pubs, useSubs, notifyMiddleware, }: {
/**

@@ -33,6 +33,2 @@ * The uncontrolled initial state of the slice.

notifyMiddleware?: ((notify: () => void) => () => void) | undefined;
/**
* Add additionally functionality to the slice before it handles each event. For example a logger.
*/
logger?: ((name: 'get' | 'notify-subs' | 'add-sub' | 'rm-sub' | 'notify-sub', state: State) => unknown) | undefined;
}) => {

@@ -39,0 +35,0 @@ /**

2

dist/index.js

@@ -1,1 +0,1 @@

function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=/*#__PURE__*/e(require("react"));function t(e){var n={exports:{}};return e(n,n.exports),n.exports}var u="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},r=n.default.useSyncExternalStore,o=n.default.useRef,i=n.default.useEffect,f=n.default.useMemo,c=n.default.useDebugValue,a={useSyncExternalStoreWithSelector:function(e,n,t,a,l){var s=o(null);if(null===s.current){var _={hasValue:!1,value:null};s.current=_}else _=s.current;s=f(function(){function e(e){if(!i){if(i=!0,r=e,e=a(e),void 0!==l&&_.hasValue){var n=_.value;if(l(n,e))return o=n}return o=e}if(n=o,u(r,e))return n;var t=a(e);return void 0!==l&&l(n,t)?n:(r=e,o=t)}var r,o,i=!1,f=void 0===t?null:t;return[function(){return e(n())},null===f?void 0:function(){return e(f())}]},[n,t,a,l]);var v=r(e,s[0],s[1]);return i(function(){_.hasValue=!0,_.value=v},[v]),c(v),v}},l=t(function(e,t){"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=n.default,u="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},r=e.useSyncExternalStore,o=e.useRef,i=e.useEffect,f=e.useMemo,c=e.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,n,t,a,l){var s,_=o(null);null===_.current?_.current=s={hasValue:!1,value:null}:s=_.current;var v=f(function(){var e,r,o=!1,i=function(n){if(!o){o=!0,e=n;var t=a(n);if(void 0!==l&&s.hasValue){var i=s.value;if(l(i,t))return r=i,i}return r=t,t}var f=r;if(u(e,n))return f;var c=a(n);return void 0!==l&&l(f,c)?f:(e=n,r=c,c)},f=void 0===t?null:t;return[function(){return i(n())},null===f?void 0:function(){return i(f())}]},[n,t,a,l]),O=r(e,v[0],v[1]);return i(function(){s.hasValue=!0,s.value=O},[O]),c(O),O},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()}),s=t(function(e){e.exports="production"===process.env.NODE_ENV?a:l});exports.create=function(e){var n=e.pubs,t=e.useSubs,u=e.notifyMiddleware,r=e.logger,o=e.initState,i=new Set,f=function(){return i.forEach(function(e){return e()})},c=u?u(f):f,a=r||function(){},l={get:function(){return a("get",o),o},pub:function(e){o=e(o),a("notify-subs",o),c()},sub:function(e,n,t){var u=e(o),r=function(){var r=e(o);(t?!t(u,r):u!==r)&&(a("notify-sub",o),n(r),u=r)};return a("add-sub",o),i.add(r),function(){a("rm-sub",o),i.delete(r)}},useSub:function(e,n){return s.useSyncExternalStoreWithSelector(l.sub,l.get,void 0,e,n)}};return n&&Object.keys(n).forEach(function(e){l[e]=function(t){return l.pub(function(u){return n[e](u,t)})}}),t&&Object.keys(t).forEach(function(e){l[e]=function(n){var u=t[e](n);return l.useSub(u.select,u.isEqual)}}),l};
function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=/*#__PURE__*/e(require("react"));function t(e){var n={exports:{}};return e(n,n.exports),n.exports}var r="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},u=n.default.useSyncExternalStore,o=n.default.useRef,i=n.default.useEffect,f=n.default.useMemo,c=n.default.useDebugValue,a={useSyncExternalStoreWithSelector:function(e,n,t,a,l){var s=o(null);if(null===s.current){var _={hasValue:!1,value:null};s.current=_}else _=s.current;s=f(function(){function e(e){if(!i){if(i=!0,u=e,e=a(e),void 0!==l&&_.hasValue){var n=_.value;if(l(n,e))return o=n}return o=e}if(n=o,r(u,e))return n;var t=a(e);return void 0!==l&&l(n,t)?n:(u=e,o=t)}var u,o,i=!1,f=void 0===t?null:t;return[function(){return e(n())},null===f?void 0:function(){return e(f())}]},[n,t,a,l]);var v=u(e,s[0],s[1]);return i(function(){_.hasValue=!0,_.value=v},[v]),c(v),v}},l=t(function(e,t){"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=n.default,r="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},u=e.useSyncExternalStore,o=e.useRef,i=e.useEffect,f=e.useMemo,c=e.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,n,t,a,l){var s,_=o(null);null===_.current?_.current=s={hasValue:!1,value:null}:s=_.current;var v=f(function(){var e,u,o=!1,i=function(n){if(!o){o=!0,e=n;var t=a(n);if(void 0!==l&&s.hasValue){var i=s.value;if(l(i,t))return u=i,i}return u=t,t}var f=u;if(r(e,n))return f;var c=a(n);return void 0!==l&&l(f,c)?f:(e=n,u=c,c)},f=void 0===t?null:t;return[function(){return i(n())},null===f?void 0:function(){return i(f())}]},[n,t,a,l]),O=u(e,v[0],v[1]);return i(function(){s.hasValue=!0,s.value=O},[O]),c(O),O},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()}),s=t(function(e){e.exports="production"===process.env.NODE_ENV?a:l});exports.create=function(e){var n=e.pubs,t=e.useSubs,r=e.notifyMiddleware,u=e.initState,o=new Set,i=function(){return o.forEach(function(e){return e()})},f=r?r(i):i,c={get:function(){return u},pub:function(e){u=e(u),f()},sub:function(e,n,t){var r=e(u),i=function(){var o=e(u);(t?!t(r,o):r!==o)&&(n(o),r=o)};return o.add(i),function(){o.delete(i)}},useSub:function(e,n){return s.useSyncExternalStoreWithSelector(c.sub,c.get,void 0,e,n)}};return n&&Object.keys(n).forEach(function(e){c[e]=function(t){return c.pub(function(r){return n[e](r,t)})}}),t&&Object.keys(t).forEach(function(e){c[e]=function(n){var r=t[e](n);return c.useSub(r.select,r.isEqual)}}),c};

@@ -1,1 +0,1 @@

import n from"react";function e(n){var e={exports:{}};return n(e,e.exports),e.exports}var r="function"==typeof Object.is?Object.is:function(n,e){return n===e&&(0!==n||1/n==1/e)||n!=n&&e!=e},t=n.useSyncExternalStore,u=n.useRef,o=n.useEffect,i=n.useMemo,c=n.useDebugValue,f={useSyncExternalStoreWithSelector:function(n,e,f,a,l){var s=u(null);if(null===s.current){var _={hasValue:!1,value:null};s.current=_}else _=s.current;s=i(function(){function n(n){if(!o){if(o=!0,t=n,n=a(n),void 0!==l&&_.hasValue){var e=_.value;if(l(e,n))return u=e}return u=n}if(e=u,r(t,n))return e;var i=a(n);return void 0!==l&&l(e,i)?e:(t=n,u=i)}var t,u,o=!1,i=void 0===f?null:f;return[function(){return n(e())},null===i?void 0:function(){return n(i())}]},[e,f,a,l]);var O=t(n,s[0],s[1]);return o(function(){_.hasValue=!0,_.value=O},[O]),c(O),O}},a=e(function(e,r){"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e="function"==typeof Object.is?Object.is:function(n,e){return n===e&&(0!==n||1/n==1/e)||n!=n&&e!=e},t=n.useSyncExternalStore,u=n.useRef,o=n.useEffect,i=n.useMemo,c=n.useDebugValue;r.useSyncExternalStoreWithSelector=function(n,r,f,a,l){var s,_=u(null);null===_.current?_.current=s={hasValue:!1,value:null}:s=_.current;var O=i(function(){var n,t,u=!1,o=function(r){if(!u){u=!0,n=r;var o=a(r);if(void 0!==l&&s.hasValue){var i=s.value;if(l(i,o))return t=i,i}return t=o,o}var c=t;if(e(n,r))return c;var f=a(r);return void 0!==l&&l(c,f)?c:(n=r,t=f,f)},i=void 0===f?null:f;return[function(){return o(r())},null===i?void 0:function(){return o(i())}]},[r,f,a,l]),v=t(n,O[0],O[1]);return o(function(){s.hasValue=!0,s.value=v},[v]),c(v),v},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()}),l=e(function(n){n.exports="production"===process.env.NODE_ENV?f:a}),s=function(n){var e=n.pubs,r=n.useSubs,t=n.notifyMiddleware,u=n.logger,o=n.initState,i=new Set,c=function(){return i.forEach(function(n){return n()})},f=t?t(c):c,a=u||function(){},s={get:function(){return a("get",o),o},pub:function(n){o=n(o),a("notify-subs",o),f()},sub:function(n,e,r){var t=n(o),u=function(){var u=n(o);(r?!r(t,u):t!==u)&&(a("notify-sub",o),e(u),t=u)};return a("add-sub",o),i.add(u),function(){a("rm-sub",o),i.delete(u)}},useSub:function(n,e){return l.useSyncExternalStoreWithSelector(s.sub,s.get,void 0,n,e)}};return e&&Object.keys(e).forEach(function(n){s[n]=function(r){return s.pub(function(t){return e[n](t,r)})}}),r&&Object.keys(r).forEach(function(n){s[n]=function(e){var t=r[n](e);return s.useSub(t.select,t.isEqual)}}),s};export{s as create};
import e from"react";function n(e){var n={exports:{}};return e(n,n.exports),n.exports}var r="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},t=e.useSyncExternalStore,u=e.useRef,o=e.useEffect,i=e.useMemo,c=e.useDebugValue,f={useSyncExternalStoreWithSelector:function(e,n,f,a,l){var s=u(null);if(null===s.current){var _={hasValue:!1,value:null};s.current=_}else _=s.current;s=i(function(){function e(e){if(!o){if(o=!0,t=e,e=a(e),void 0!==l&&_.hasValue){var n=_.value;if(l(n,e))return u=n}return u=e}if(n=u,r(t,e))return n;var i=a(e);return void 0!==l&&l(n,i)?n:(t=e,u=i)}var t,u,o=!1,i=void 0===f?null:f;return[function(){return e(n())},null===i?void 0:function(){return e(i())}]},[n,f,a,l]);var O=t(e,s[0],s[1]);return o(function(){_.hasValue=!0,_.value=O},[O]),c(O),O}},a=n(function(n,r){"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var n="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},t=e.useSyncExternalStore,u=e.useRef,o=e.useEffect,i=e.useMemo,c=e.useDebugValue;r.useSyncExternalStoreWithSelector=function(e,r,f,a,l){var s,_=u(null);null===_.current?_.current=s={hasValue:!1,value:null}:s=_.current;var O=i(function(){var e,t,u=!1,o=function(r){if(!u){u=!0,e=r;var o=a(r);if(void 0!==l&&s.hasValue){var i=s.value;if(l(i,o))return t=i,i}return t=o,o}var c=t;if(n(e,r))return c;var f=a(r);return void 0!==l&&l(c,f)?c:(e=r,t=f,f)},i=void 0===f?null:f;return[function(){return o(r())},null===i?void 0:function(){return o(i())}]},[r,f,a,l]),v=t(e,O[0],O[1]);return o(function(){s.hasValue=!0,s.value=v},[v]),c(v),v},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()}),l=n(function(e){e.exports="production"===process.env.NODE_ENV?f:a}),s=function(e){var n=e.pubs,r=e.useSubs,t=e.notifyMiddleware,u=e.initState,o=new Set,i=function(){return o.forEach(function(e){return e()})},c=t?t(i):i,f={get:function(){return u},pub:function(e){u=e(u),c()},sub:function(e,n,r){var t=e(u),i=function(){var o=e(u);(r?!r(t,o):t!==o)&&(n(o),t=o)};return o.add(i),function(){o.delete(i)}},useSub:function(e,n){return l.useSyncExternalStoreWithSelector(f.sub,f.get,void 0,e,n)}};return n&&Object.keys(n).forEach(function(e){f[e]=function(r){return f.pub(function(t){return n[e](t,r)})}}),r&&Object.keys(r).forEach(function(e){f[e]=function(n){var t=r[e](n);return f.useSub(t.select,t.isEqual)}}),f};export{s as create};

@@ -1,1 +0,1 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e||self).observableSlice={},e.react)}(this,function(e,n){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=/*#__PURE__*/t(n);function r(e){var n={exports:{}};return e(n,n.exports),n.exports}var o="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},i=u.default.useSyncExternalStore,f=u.default.useRef,c=u.default.useEffect,a=u.default.useMemo,l=u.default.useDebugValue,s={useSyncExternalStoreWithSelector:function(e,n,t,u,r){var s=f(null);if(null===s.current){var _={hasValue:!1,value:null};s.current=_}else _=s.current;s=a(function(){function e(e){if(!c){if(c=!0,i=e,e=u(e),void 0!==r&&_.hasValue){var n=_.value;if(r(n,e))return f=n}return f=e}if(n=f,o(i,e))return n;var t=u(e);return void 0!==r&&r(n,t)?n:(i=e,f=t)}var i,f,c=!1,a=void 0===t?null:t;return[function(){return e(n())},null===a?void 0:function(){return e(a())}]},[n,t,u,r]);var d=i(e,s[0],s[1]);return c(function(){_.hasValue=!0,_.value=d},[d]),l(d),d}},_=r(function(e,n){"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=u.default,t="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},r=e.useSyncExternalStore,o=e.useRef,i=e.useEffect,f=e.useMemo,c=e.useDebugValue;n.useSyncExternalStoreWithSelector=function(e,n,u,a,l){var s,_=o(null);null===_.current?_.current=s={hasValue:!1,value:null}:s=_.current;var d=f(function(){var e,r,o=!1,i=function(n){if(!o){o=!0,e=n;var u=a(n);if(void 0!==l&&s.hasValue){var i=s.value;if(l(i,u))return r=i,i}return r=u,u}var f=r;if(t(e,n))return f;var c=a(n);return void 0!==l&&l(f,c)?f:(e=n,r=c,c)},f=void 0===u?null:u;return[function(){return i(n())},null===f?void 0:function(){return i(f())}]},[n,u,a,l]),v=r(e,d[0],d[1]);return i(function(){s.hasValue=!0,s.value=v},[v]),c(v),v},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()}),d=r(function(e){e.exports="production"===process.env.NODE_ENV?s:_});e.create=function(e){var n=e.pubs,t=e.useSubs,u=e.notifyMiddleware,r=e.logger,o=e.initState,i=new Set,f=function(){return i.forEach(function(e){return e()})},c=u?u(f):f,a=r||function(){},l={get:function(){return a("get",o),o},pub:function(e){o=e(o),a("notify-subs",o),c()},sub:function(e,n,t){var u=e(o),r=function(){var r=e(o);(t?!t(u,r):u!==r)&&(a("notify-sub",o),n(r),u=r)};return a("add-sub",o),i.add(r),function(){a("rm-sub",o),i.delete(r)}},useSub:function(e,n){return d.useSyncExternalStoreWithSelector(l.sub,l.get,void 0,e,n)}};return n&&Object.keys(n).forEach(function(e){l[e]=function(t){return l.pub(function(u){return n[e](u,t)})}}),t&&Object.keys(t).forEach(function(e){l[e]=function(n){var u=t[e](n);return l.useSub(u.select,u.isEqual)}}),l}});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e||self).observableSlice={},e.react)}(this,function(e,n){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/t(n);function u(e){var n={exports:{}};return e(n,n.exports),n.exports}var o="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},i=r.default.useSyncExternalStore,f=r.default.useRef,c=r.default.useEffect,a=r.default.useMemo,l=r.default.useDebugValue,s={useSyncExternalStoreWithSelector:function(e,n,t,r,u){var s=f(null);if(null===s.current){var _={hasValue:!1,value:null};s.current=_}else _=s.current;s=a(function(){function e(e){if(!c){if(c=!0,i=e,e=r(e),void 0!==u&&_.hasValue){var n=_.value;if(u(n,e))return f=n}return f=e}if(n=f,o(i,e))return n;var t=r(e);return void 0!==u&&u(n,t)?n:(i=e,f=t)}var i,f,c=!1,a=void 0===t?null:t;return[function(){return e(n())},null===a?void 0:function(){return e(a())}]},[n,t,r,u]);var d=i(e,s[0],s[1]);return c(function(){_.hasValue=!0,_.value=d},[d]),l(d),d}},_=u(function(e,n){"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=r.default,t="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},u=e.useSyncExternalStore,o=e.useRef,i=e.useEffect,f=e.useMemo,c=e.useDebugValue;n.useSyncExternalStoreWithSelector=function(e,n,r,a,l){var s,_=o(null);null===_.current?_.current=s={hasValue:!1,value:null}:s=_.current;var d=f(function(){var e,u,o=!1,i=function(n){if(!o){o=!0,e=n;var r=a(n);if(void 0!==l&&s.hasValue){var i=s.value;if(l(i,r))return u=i,i}return u=r,r}var f=u;if(t(e,n))return f;var c=a(n);return void 0!==l&&l(f,c)?f:(e=n,u=c,c)},f=void 0===r?null:r;return[function(){return i(n())},null===f?void 0:function(){return i(f())}]},[n,r,a,l]),v=u(e,d[0],d[1]);return i(function(){s.hasValue=!0,s.value=v},[v]),c(v),v},"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()}),d=u(function(e){e.exports="production"===process.env.NODE_ENV?s:_});e.create=function(e){var n=e.pubs,t=e.useSubs,r=e.notifyMiddleware,u=e.initState,o=new Set,i=function(){return o.forEach(function(e){return e()})},f=r?r(i):i,c={get:function(){return u},pub:function(e){u=e(u),f()},sub:function(e,n,t){var r=e(u),i=function(){var o=e(u);(t?!t(r,o):r!==o)&&(n(o),r=o)};return o.add(i),function(){o.delete(i)}},useSub:function(e,n){return d.useSyncExternalStoreWithSelector(c.sub,c.get,void 0,e,n)}};return n&&Object.keys(n).forEach(function(e){c[e]=function(t){return c.pub(function(r){return n[e](r,t)})}}),t&&Object.keys(t).forEach(function(e){c[e]=function(n){var r=t[e](n);return c.useSub(r.select,r.isEqual)}}),c}});
{
"name": "observable-slice",
"version": "0.0.19",
"version": "0.0.20",
"description": "An observable for global state that can be subscribed to with react hooks, or callbacks",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -109,3 +109,2 @@ [![license-shield]][license-url] [![linkedin-shield]][linkedin-url] ![size-url] ![size-url2] [![npm-v]][npm-url] [![gh-shield]][gh-url]

| $useSub | fn | | Each entry defined in create.subs will create a react hook that may be consumed to subscribe to the slice. These hooks may also accept one parameter. For example, the useTodo subscription may accept the id of the todo to subscribe to. |
| logger | fn | | Add additionally functionality to the slice before it handles each eventFor example a logger, or a persister. |
## Roadmap

@@ -112,0 +111,0 @@

@@ -312,25 +312,2 @@ import { act, renderHook } from '@testing-library/react';

});
it('runs side effects before internal events are handled', () => {
const logger = jest.fn();
const slice = create({
initState: 0,
logger,
});
slice.get();
expect(logger).toHaveBeenCalledWith('get', 0);
const rm = slice.sub(
s => s,
() => {}
);
expect(logger).toHaveBeenCalledWith('add-sub', 0);
slice.pub(() => 1);
expect(logger).toHaveBeenCalledWith('notify-subs', 1);
expect(logger).toHaveBeenCalledWith('notify-sub', 1);
rm();
expect(logger).toHaveBeenCalledWith('rm-sub', 1);
});
it('creates pubs that do not need args', () => {

@@ -337,0 +314,0 @@ const slice = create({

@@ -24,3 +24,2 @@ import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector';

notifyMiddleware,
logger,
}: {

@@ -50,9 +49,2 @@ /**

notifyMiddleware?: (notify: () => void) => () => void;
/**
* Add additionally functionality to the slice before it handles each event. For example a logger.
*/
logger?: (
name: 'get' | 'notify-subs' | 'add-sub' | 'rm-sub' | 'notify-sub',
state: State
) => unknown;
}) => {

@@ -63,7 +55,5 @@ let state = initState;

const notify = notifyMiddleware ? notifyMiddleware(_notify) : _notify;
const log = logger ? logger : () => {};
const res: any = {
get: () => {
log('get', state);
return state;

@@ -73,3 +63,2 @@ },

state = replace(state);
log('notify-subs', state);
notify();

@@ -87,3 +76,2 @@ },

if (update) {
log('notify-sub', state);
cb(next);

@@ -94,7 +82,5 @@ prev = next;

log('add-sub', state);
subscribers.add(sub);
return () => {
log('rm-sub', state);
subscribers.delete(sub);

@@ -101,0 +87,0 @@ };

Sorry, the diff of this file is not supported yet

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