redux-awaiter
Advanced tools
Comparing version 0.0.6 to 0.1.0
@@ -21,6 +21,6 @@ export declare type ActionType = string; | ||
private constructor(); | ||
produce<P, M>(awaiter: Awaiter<P, M>): void; | ||
consume<P, M>(action: Action<P, M>): void; | ||
produce<P = {}, M = {}>(awaiter: Awaiter<P, M>): number; | ||
consume<P = {}, M = {}>(action: Action<P, M>): number; | ||
} | ||
declare const awaiters: Awaiters; | ||
export default awaiters; |
@@ -35,5 +35,7 @@ "use strict"; | ||
this.awaiters = this.awaiters.concat([awaiter]); | ||
return this.awaiters.length; | ||
}; | ||
Awaiters.prototype.consume = function (action) { | ||
this.awaiters = this.awaiters.filter(Awaiters.consumer(action)); | ||
return this.awaiters.length; | ||
}; | ||
@@ -40,0 +42,0 @@ Awaiters.instance = new Awaiters(); |
@@ -1,4 +0,3 @@ | ||
import { Middleware } from 'redux'; | ||
export declare const createAwaiterMiddleware: () => Middleware; | ||
export * from './awaiters'; | ||
export * from './createAwaiterMiddleware'; | ||
export * from './operations'; |
"use strict"; | ||
import awaiters from './awaiters'; | ||
export var createAwaiterMiddleware = function () { return function () { return function (next) { return function (action) { | ||
awaiters.consume(action); | ||
return next(action); | ||
}; }; }; }; | ||
export * from './awaiters'; | ||
export * from './createAwaiterMiddleware'; | ||
export * from './operations'; | ||
//# sourceMappingURL=index.js.map |
@@ -36,5 +36,7 @@ "use strict"; | ||
this.awaiters = this.awaiters.concat([awaiter]); | ||
return this.awaiters.length; | ||
}; | ||
Awaiters.prototype.consume = function (action) { | ||
this.awaiters = this.awaiters.filter(Awaiters.consumer(action)); | ||
return this.awaiters.length; | ||
}; | ||
@@ -41,0 +43,0 @@ Awaiters.instance = new Awaiters(); |
@@ -6,9 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var awaiters_1 = require("./awaiters"); | ||
exports.createAwaiterMiddleware = function () { return function () { return function (next) { return function (action) { | ||
awaiters_1.default.consume(action); | ||
return next(action); | ||
}; }; }; }; | ||
__export(require("./awaiters")); | ||
__export(require("./createAwaiterMiddleware")); | ||
__export(require("./operations")); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "redux-awaiter", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "A Redux middleware for giving opportunities to await and receive actions in anywhere", | ||
@@ -61,3 +61,3 @@ "main": "lib/index.js", | ||
"redux": "^3.7.2", | ||
"ts-jest": "^21.0.1", | ||
"ts-jest": "^21.1.0", | ||
"tslint": "^5.7.0", | ||
@@ -64,0 +64,0 @@ "tslint-config-airbnb": "^5.3.0", |
@@ -51,8 +51,10 @@ export type ActionType = string; | ||
public produce<P, M>(awaiter: Awaiter<P, M>) { | ||
public produce<P = {}, M = {}>(awaiter: Awaiter<P, M>) { | ||
this.awaiters = [...this.awaiters, awaiter]; | ||
return this.awaiters.length; | ||
} | ||
public consume<P, M>(action: Action<P, M>) { | ||
public consume<P = {}, M = {}>(action: Action<P, M>) { | ||
this.awaiters = this.awaiters.filter(Awaiters.consumer(action)); | ||
return this.awaiters.length; | ||
} | ||
@@ -59,0 +61,0 @@ } |
@@ -1,11 +0,3 @@ | ||
import { Middleware } from 'redux'; | ||
import awaiters from './awaiters'; | ||
export const createAwaiterMiddleware = (): Middleware => () => next => (action) => { | ||
awaiters.consume(action as any); // cast AnyAction to standard Action<P, M> | ||
return next(action); | ||
}; | ||
export * from './awaiters'; | ||
export * from './createAwaiterMiddleware'; | ||
export * from './operations'; |
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
24101
46
277