reshow-flux-base
Advanced tools
Comparing version 1.0.0 to 1.1.0
"use strict"; | ||
exports.__esModule = true; | ||
exports.refineAction = exports.createReducer = void 0; | ||
exports.refineAction = exports.getMitt = exports.createReducer = void 0; | ||
// @ts-check | ||
@@ -81,3 +81,3 @@ | ||
*/ | ||
var getMitt = function getMitt() { | ||
var getMitt = exports.getMitt = function getMitt() { | ||
/** | ||
@@ -98,3 +98,3 @@ * @type FluxHandler<StateType, ActionType>[] | ||
add: function add(handler) { | ||
return pool.unshift(handler); | ||
return pool.push(handler); | ||
}, | ||
@@ -110,11 +110,8 @@ /** | ||
* @type Emiter<StateType, ActionType>['emit'] | ||
* @see https://github.com/react-atomic/reshow/issues/96 | ||
*/ | ||
emit: function emit(state, action, prevState) { | ||
var nextExec = pool.slice(0); //https://github.com/react-atomic/reshow/issues/96 | ||
setTimeout(function () { | ||
var i = nextExec.length; | ||
while (i--) { | ||
nextExec[i](state, action, prevState); | ||
} | ||
}); | ||
return pool.slice(0).reduce(function (curState, curFunc) { | ||
return curFunc(curState, action, prevState); | ||
}, state); | ||
} | ||
@@ -179,11 +176,12 @@ }; | ||
state.current = endingState; | ||
mitt.emit(endingState, refinedAction, startingState); | ||
setTimeout(function () { | ||
return mitt.emit(endingState, refinedAction, startingState); | ||
}); | ||
} | ||
return endingState; | ||
return state.current; | ||
}; | ||
var store = { | ||
reset: function reset() { | ||
if (mitt.reset()) { | ||
state.current = callfunc(initState)(); | ||
} | ||
mitt.reset(); | ||
state.current = callfunc(initState)(); | ||
return state.current; | ||
@@ -190,0 +188,0 @@ }, |
"use strict"; | ||
exports.__esModule = true; | ||
exports.refineAction = exports.createReducer = void 0; | ||
exports.refineAction = exports.getMitt = exports.createReducer = void 0; | ||
var _createReducer = require("./createReducer.js"); | ||
exports.createReducer = _createReducer.createReducer; | ||
exports.refineAction = _createReducer.refineAction; | ||
exports.refineAction = _createReducer.refineAction; | ||
exports.getMitt = _createReducer.getMitt; |
@@ -18,5 +18,5 @@ "use strict"; | ||
* @callback FluxHandler | ||
* @param {StateType} NextState | ||
* @param {RefinedAction<ActionType>} Action | ||
* @param {StateType} PrevState | ||
* @param {StateType=} NextState | ||
* @param {RefinedAction<ActionType>=} Action | ||
* @param {StateType=} PrevState | ||
* @returns{any} | ||
@@ -29,5 +29,5 @@ */ | ||
* @callback EmitterEmitCall | ||
* @param {StateType} state | ||
* @param {RefinedAction<ActionType>} action | ||
* @param {StateType} prevState | ||
* @param {StateType=} state | ||
* @param {RefinedAction<ActionType>=} action | ||
* @param {StateType=} prevState | ||
*/ | ||
@@ -34,0 +34,0 @@ /** |
{ | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"name": "reshow-flux-base", | ||
@@ -4,0 +4,0 @@ "repository": { |
@@ -1,12 +0,32 @@ | ||
export function refineAction<StateType, ActionType>(action: DispatchAction<StateType, ActionType>, params?: Payload, prevState?: StateType): import("./type").ActionObject | ActionType; | ||
export function getMitt<StateType, ActionType>(): { | ||
/** | ||
* @type Emiter<StateType, ActionType>['reset'] | ||
*/ | ||
reset: Emiter<StateType, ActionType>["reset"]; | ||
/** | ||
* @type Emiter<StateType, ActionType>['add'] | ||
*/ | ||
add: Emiter<StateType, ActionType>["add"]; | ||
/** | ||
* >>> 0 for change indexOf return -1 to 4294967295 | ||
* @type Emiter<StateType, ActionType>['remove'] | ||
*/ | ||
remove: Emiter<StateType, ActionType>["remove"]; | ||
/** | ||
* @type Emiter<StateType, ActionType>['emit'] | ||
* @see https://github.com/react-atomic/reshow/issues/96 | ||
*/ | ||
emit: Emiter<StateType, ActionType>["emit"]; | ||
}; | ||
export function refineAction<StateType, ActionType>(action: DispatchAction<StateType, ActionType>, params?: Payload, prevState?: StateType): ActionObject | ActionType; | ||
export function createReducer<StateType, ActionType>(reducer: ReducerType<StateType, ActionType>, initState?: InitStateType<StateType>): [StoreObject<StateType, ActionType>, DispatchFunction<StateType, ActionType>]; | ||
export type InitStateType<StateType> = import('./type').InitStateType<StateType>; | ||
export type ReducerType<StateType, ActionType> = import('./type').ReducerType<StateType, ActionType>; | ||
export type DispatchFunction<StateType, ActionType> = import('./type').DispatchFunction<StateType, ActionType>; | ||
export type DispatchAction<StateType, ActionType> = import('./type').DispatchAction<StateType, ActionType>; | ||
export type ActionObject = import('./type').ActionObject; | ||
export type StoreObject<StateType, ActionType> = import('./type').StoreObject<StateType, ActionType>; | ||
export type Emiter<StateType, ActionType> = import('./type').Emiter<StateType, ActionType>; | ||
export type FluxHandler<StateType, ActionType> = import('./type').FluxHandler<StateType, ActionType>; | ||
export type RefinedAction<ActionType> = import('./type').RefinedAction<ActionType>; | ||
export type Payload = import('./type').Payload; | ||
export type InitStateType<StateType> = import("./type").InitStateType<StateType>; | ||
export type ReducerType<StateType, ActionType> = import("./type").ReducerType<StateType, ActionType>; | ||
export type DispatchFunction<StateType, ActionType> = import("./type").DispatchFunction<StateType, ActionType>; | ||
export type DispatchAction<StateType, ActionType> = import("./type").DispatchAction<StateType, ActionType>; | ||
export type ActionObject = import("./type").ActionObject; | ||
export type StoreObject<StateType, ActionType> = import("./type").StoreObject<StateType, ActionType>; | ||
export type Emiter<StateType, ActionType> = import("./type").Emiter<StateType, ActionType>; | ||
export type FluxHandler<StateType, ActionType> = import("./type").FluxHandler<StateType, ActionType>; | ||
export type RefinedAction<ActionType> = import("./type").RefinedAction<ActionType>; | ||
export type Payload = import("./type").Payload; |
@@ -6,2 +6,2 @@ export type InitStateType<StateType> = import("./type").InitStateType<StateType>; | ||
export type ActionObject = import("./type").ActionObject; | ||
export { createReducer, refineAction } from "./createReducer"; | ||
export { createReducer, refineAction, getMitt } from "./createReducer"; |
@@ -7,4 +7,4 @@ declare const _default: {}; | ||
export type RefinedAction<ActionType = ActionObject> = ActionType | ActionObject; | ||
export type FluxHandler<StateType, ActionType> = (NextState: StateType, Action: RefinedAction<ActionType>, PrevState: StateType) => any; | ||
export type EmitterEmitCall<StateType, ActionType> = (state: StateType, action: RefinedAction<ActionType>, prevState: StateType) => any; | ||
export type FluxHandler<StateType, ActionType> = (NextState?: StateType | undefined, Action?: RefinedAction<ActionType> | undefined, PrevState?: StateType | undefined) => any; | ||
export type EmitterEmitCall<StateType, ActionType> = (state?: StateType | undefined, action?: RefinedAction<ActionType> | undefined, prevState?: StateType | undefined) => any; | ||
export type EmitterResetCall<StateType, ActionType> = () => FluxHandler<StateType, ActionType>[]; | ||
@@ -11,0 +11,0 @@ export type EmitterAddCall<StateType, ActionType> = (handler: FluxHandler<StateType, ActionType>) => number; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
28468
845