react-app-store-manager 2.0.0 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/Store.d.ts CHANGED
@@ -2,27 +2,22 @@ import React, { Context } from "react";
2
2
  interface ListenerInterface {
3
3
  onUpdate(): void;
4
4
  }
5
- export interface ActionsInterface {
6
- [action: string]: (payload: any) => any;
7
- }
8
5
  export interface StoreInterface<Value, Action> {
9
6
  context: Context<Value>;
10
7
  value: Value;
11
- actions: ActionsInterface;
12
- listeners: ListenerInterface[];
13
8
  update(store: (store: Value) => Value): void;
14
- action(actions: (action: Action) => any): void;
9
+ action(actions: (action: Action) => any): any;
15
10
  subscribe(listener: ListenerInterface): void;
16
11
  unsubscribe(listener: ListenerInterface): void;
17
12
  }
18
13
  export declare class Store<Value, Action> implements StoreInterface<Value, Action> {
19
14
  context: React.Context<Value>;
20
15
  value: Value;
21
- actions: any;
22
- listeners: ListenerInterface[];
23
- constructor(value: Value, actions: any);
16
+ private readonly actions?;
17
+ private listeners;
18
+ constructor(value: Value, actions?: Action);
24
19
  update(callback: any): void;
25
- action(callback: any): void;
20
+ action(callback: any): any;
26
21
  subscribe(listener: ListenerInterface): void;
27
22
  unsubscribe(listener: ListenerInterface): void;
28
23
  }
package/dist/Store.js CHANGED
@@ -21,7 +21,7 @@ var Store = /** @class */ (function () {
21
21
  }
22
22
  };
23
23
  Store.prototype.action = function (callback) {
24
- callback(this.actions);
24
+ return callback(this.actions);
25
25
  };
26
26
  Store.prototype.subscribe = function (listener) {
27
27
  this.listeners.push(listener);
@@ -1,2 +1,2 @@
1
1
  import { StoreInterface } from "./Store";
2
- export declare function createStore<Value, Actions>(value: Value, actions?: Actions): StoreInterface<Value, Actions>;
2
+ export declare function createStore<Value>(value: any, actions?: any): StoreInterface<Value, typeof actions>;
@@ -3,6 +3,6 @@ exports.__esModule = true;
3
3
  exports.createStore = void 0;
4
4
  var Store_1 = require("./Store");
5
5
  function createStore(value, actions) {
6
- return new Store_1.Store(value, actions !== null && actions !== void 0 ? actions : {});
6
+ return new Store_1.Store(value, actions);
7
7
  }
8
8
  exports.createStore = createStore;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-app-store-manager",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "tsc --declaration"