Socket
Socket
Sign inDemoInstall

@stencil/store

Package Overview
Dependencies
Maintainers
11
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stencil/store - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

11

dist/index.js

@@ -49,2 +49,5 @@ 'use strict';

// This function is not really exported by @stencil/core.
on('dispose', () => {
elmsToUpdate.clear();
});
on('get', (propName) => {

@@ -73,2 +76,3 @@ const elm = core.getRenderingRef();

const handlers = {
dispose: [],
get: [],

@@ -82,2 +86,8 @@ set: [],

};
const dispose = () => {
// Call first dispose as resetting the state would
// cause less updates ;)
handlers.dispose.forEach((cb) => cb());
reset();
};
const get = (propName) => {

@@ -153,2 +163,3 @@ handlers.get.forEach((cb) => cb(propName));

use,
dispose,
reset,

@@ -155,0 +166,0 @@ };

13

dist/types.d.ts
export interface Handlers<T> {
set: SetEventHandler<T>[];
dispose: DisposeEventHandler[];
get: GetEventHandler<T>[];
reset: ResetEventHandler[];
set: SetEventHandler<T>[];
}

@@ -9,5 +10,7 @@ export declare type SetEventHandler<StoreType> = (key: keyof StoreType, newValue: any, oldValue: any) => void;

export declare type ResetEventHandler = () => void;
export declare type DisposeEventHandler = () => void;
export interface OnHandler<StoreType> {
(eventName: 'set', callback: SetEventHandler<StoreType>): () => void;
(eventName: 'get', callback: GetEventHandler<StoreType>): () => void;
(eventName: 'dispose', callback: DisposeEventHandler): () => void;
(eventName: 'reset', callback: ResetEventHandler): () => void;

@@ -74,2 +77,10 @@ }

/**
* Resets the state to its original state and
* signals a dispose event to all the plugins.
*
* This method is intended for plugins to reset
* all their internal state between tests.
*/
dispose(): void;
/**
* Resets the state to its original state.

@@ -76,0 +87,0 @@ */

2

package.json
{
"name": "@stencil/store",
"version": "1.1.1",
"version": "1.2.0",
"description": "Store is a lightweight shared state library by the StencilJS core team. Implements a simple key/value map that efficiently re-renders components when necessary.",

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

@@ -116,7 +116,11 @@ # @stencil/store

#### `store.dispose()`
Resets the store and all the internal state of the store that should not survive between tests.
## Testing
Like any global state library, state should be reset between each spec test.
Use the `reset()` API in the `beforeEach` hook.
Like any global state library, state should be `dispose`d between each spec test.
Use the `dispose()` API in the `beforeEach` hook.

@@ -127,4 +131,4 @@ ```ts

beforeEach(() => {
store.reset();
store.dispose();
});
```

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