reducer-composer
Advanced tools
Comparing version 0.0.9 to 0.0.10
import { Reducer } from "./utility"; | ||
/** | ||
* @todo filter unknown actions, cannot be called with unknown actions (cannot be used as is in createCombinedReducer) | ||
* @deprecated use createKeyedByHandlers instead | ||
*/ | ||
@@ -5,0 +6,0 @@ export declare function createKeyedByReducer<State, Action extends { |
@@ -16,2 +16,3 @@ "use strict"; | ||
* @todo filter unknown actions, cannot be called with unknown actions (cannot be used as is in createCombinedReducer) | ||
* @deprecated use createKeyedByHandlers instead | ||
*/ | ||
@@ -18,0 +19,0 @@ function createKeyedByReducer(keySelector, reducer) { |
import { Reducer } from "./utility"; | ||
/** @deprecated use createKeyedHandlers instead */ | ||
export declare function createKeyedReducer<KeyAttribute extends string, State, Action extends { | ||
@@ -3,0 +4,0 @@ type: string; |
@@ -23,2 +23,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** @deprecated use createKeyedHandlers instead */ | ||
function createKeyedReducer(keyAttribute, reducer) { | ||
@@ -25,0 +26,0 @@ return function (state, action) { |
@@ -14,2 +14,5 @@ export { createReducer } from "./createReducer"; | ||
export { withInitialState } from "./withInitialState"; | ||
export { createHandlers } from "./createHandlers"; | ||
export { createKeyedHandlers } from "./createKeyedHandlers"; | ||
export { createKeyedByHandlers } from "./createKeyedByHandlers"; | ||
export * from "./utility"; |
@@ -32,2 +32,8 @@ "use strict"; | ||
exports.withInitialState = withInitialState_1.withInitialState; | ||
var createHandlers_1 = require("./createHandlers"); | ||
exports.createHandlers = createHandlers_1.createHandlers; | ||
var createKeyedHandlers_1 = require("./createKeyedHandlers"); | ||
exports.createKeyedHandlers = createKeyedHandlers_1.createKeyedHandlers; | ||
var createKeyedByHandlers_1 = require("./createKeyedByHandlers"); | ||
exports.createKeyedByHandlers = createKeyedByHandlers_1.createKeyedByHandlers; | ||
__export(require("./utility")); |
@@ -15,3 +15,3 @@ "use strict"; | ||
var reducer_composer_1 = require("reducer-composer"); | ||
var user = reducer_composer_1.createReducer()({ | ||
var userHandlers = reducer_composer_1.createHandlers()({ | ||
USER_CHANGE_NAME: function (user, _a) { | ||
@@ -26,2 +26,3 @@ var name = _a.name; | ||
}); | ||
var user = reducer_composer_1.createReducer()(userHandlers); | ||
var click = reducer_composer_1.createReducer()({ | ||
@@ -41,3 +42,3 @@ CLICK: function (clicks) { | ||
var userClickBatchReducer = reducer_composer_1.createBatchReducer("CLICKS", userClick); | ||
var usersReducer = reducer_composer_1.createKeyedReducer("id", user); | ||
var usersReducer = reducer_composer_1.createReducer()(reducer_composer_1.createKeyedHandlers("id", userHandlers)); | ||
var companyUsers = reducer_composer_1.createReducerSequence(usersReducer, reducer_composer_1.createReducer()({ | ||
@@ -44,0 +45,0 @@ USER_ADD: function (state, user) { |
@@ -20,3 +20,3 @@ "use strict"; | ||
}; | ||
var userReducer = reducer_composer_1.createReducer()({ | ||
var userHandlers = reducer_composer_1.createHandlers()({ | ||
USER_CHANGE_NAME: function (user, _a) { | ||
@@ -31,2 +31,3 @@ var name = _a.name; | ||
}); | ||
var userReducer = reducer_composer_1.createReducer()(userHandlers); | ||
userReducer(userInitialState, { | ||
@@ -83,3 +84,3 @@ type: "USER_CHANGE_BIRTH", | ||
// keyedReducer | ||
var usersReducer = reducer_composer_1.createKeyedReducer("id", userReducer); | ||
var usersReducer = reducer_composer_1.createReducer()(reducer_composer_1.createKeyedHandlers("id", userHandlers)); | ||
usersReducer({}, { type: "USER_CHANGE_NAME", payload: { id: "42", name: "John Doe" } }); | ||
@@ -86,0 +87,0 @@ // createReducerSequence |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"license": "MIT", | ||
@@ -14,0 +14,0 @@ "author": "Frederik Batuna", |
@@ -95,3 +95,4 @@ # reducer-composer | ||
[ ] handle unknown actions on keyed and keyedBy reducer | ||
[ ] remove deprecated methods | ||
[ ] change createReducer signature in favor of createHandlers | ||
[ ] documentation | ||
@@ -98,0 +99,0 @@ [ ] dtslint tests |
@@ -5,2 +5,3 @@ import { Reducer } from "./utility"; | ||
* @todo filter unknown actions, cannot be called with unknown actions (cannot be used as is in createCombinedReducer) | ||
* @deprecated use createKeyedByHandlers instead | ||
*/ | ||
@@ -7,0 +8,0 @@ export function createKeyedByReducer< |
import { Reducer } from "./utility"; | ||
/** @deprecated use createKeyedHandlers instead */ | ||
export function createKeyedReducer< | ||
@@ -4,0 +5,0 @@ KeyAttribute extends string, |
@@ -14,2 +14,5 @@ export { createReducer } from "./createReducer"; | ||
export { withInitialState } from "./withInitialState"; | ||
export { createHandlers } from "./createHandlers"; | ||
export { createKeyedHandlers } from "./createKeyedHandlers"; | ||
export { createKeyedByHandlers } from "./createKeyedByHandlers"; | ||
export * from "./utility"; |
@@ -6,6 +6,7 @@ import { | ||
createBatchReducer, | ||
createKeyedReducer, | ||
createReducerCrudHandlers, | ||
createReducerOnAction, | ||
ActionOfReducer, | ||
createHandlers, | ||
createKeyedHandlers, | ||
ignore | ||
@@ -19,4 +20,3 @@ } from "reducer-composer"; | ||
} | ||
const user = createReducer<User>()({ | ||
const userHandlers = createHandlers<User>()({ | ||
USER_CHANGE_NAME(user, { name }: { name: string }) { | ||
@@ -29,2 +29,3 @@ return { ...user, name }; | ||
}); | ||
const user = createReducer<User>()(userHandlers); | ||
@@ -47,3 +48,5 @@ const click = createReducer<number>()({ | ||
const usersReducer = createKeyedReducer("id", user); | ||
const usersReducer = createReducer<Record<string, User>>()( | ||
createKeyedHandlers("id", userHandlers) | ||
); | ||
@@ -50,0 +53,0 @@ const companyUsers = createReducerSequence( |
@@ -6,3 +6,2 @@ import { | ||
ActionOfReducer, | ||
createKeyedReducer, | ||
createReducerSequence, | ||
@@ -14,3 +13,6 @@ createReducerOnAction, | ||
createReducerCrudHandlers, | ||
createBatchHandler | ||
createBatchHandler, | ||
createHandlers, | ||
createKeyedHandlers, | ||
createKeyedReducer | ||
} from "reducer-composer"; | ||
@@ -30,3 +32,3 @@ | ||
}; | ||
const userReducer = createReducer<User>()({ | ||
const userHandlers = createHandlers<User>()({ | ||
USER_CHANGE_NAME(user, { name }: { name: string }) { | ||
@@ -39,2 +41,3 @@ return { ...user, name }; | ||
}); | ||
const userReducer = createReducer<User>()(userHandlers); | ||
userReducer(userInitialState, { | ||
@@ -100,3 +103,5 @@ type: "USER_CHANGE_BIRTH", | ||
const usersReducer = createKeyedReducer("id", userReducer); | ||
const usersReducer = createReducer<Record<string, User>>()( | ||
createKeyedHandlers("id", userHandlers) | ||
); | ||
usersReducer( | ||
@@ -103,0 +108,0 @@ {}, |
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
67873
62
1760
103