@beef-flux/store
Advanced tools
Comparing version 0.1.1 to 0.1.2
import * as React from 'react'; | ||
import { Manager } from './context'; | ||
export declare const useStore: <T>(store: Store<T>) => T; | ||
export interface StateHistory<T> { | ||
@@ -4,0 +5,0 @@ actionName: string; |
@@ -16,2 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var React = require("react"); | ||
var extend = require("extend"); | ||
@@ -25,2 +26,12 @@ var assign = require("lodash/assign"); | ||
var context_1 = require("./context"); | ||
exports.useStore = function (store) { | ||
var _a = React.useState(store.getState()), storeState = _a[0], setStoreState = _a[1]; | ||
React.useEffect(function () { | ||
store.listen(setStoreState); | ||
return function () { | ||
store.ignore(setStoreState); | ||
}; | ||
}); | ||
return storeState; | ||
}; | ||
var DEFAULT_CONFIG = { | ||
@@ -27,0 +38,0 @@ async: false, |
/// <reference types="react" /> | ||
import Actions, { ActionsManager } from './actions'; | ||
import Model from './model'; | ||
import Store from './base-store'; | ||
import Store, { useStore } from './base-store'; | ||
import { SubscribeMap } from './subscribe'; | ||
@@ -17,2 +17,2 @@ import { Manager as ContextManager } from './context'; | ||
export default _default; | ||
export { ActionsManager, SubscribeMap, ContextManager, Schema }; | ||
export { ActionsManager, SubscribeMap, ContextManager, Schema, useStore }; |
@@ -7,2 +7,3 @@ "use strict"; | ||
var base_store_1 = require("./base-store"); | ||
exports.useStore = base_store_1.useStore; | ||
var subscribe_1 = require("./subscribe"); | ||
@@ -9,0 +10,0 @@ var context_1 = require("./context"); |
{ | ||
"name": "@beef-flux/store", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Flux compatible state machine", | ||
@@ -34,3 +34,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "5202db4746ac6fb0a4813b961d3ef6c046c4728e" | ||
"gitHead": "0c36c7b7ddd3666ad12630b3e75af0fff0b1d094" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56742
1582