Comparing version 1.0.5 to 1.0.6
@@ -12,5 +12,5 @@ import { Draft } from 'immer'; | ||
readonly entity: typeof entity; | ||
readonly sliceEntity: <G extends (record: T) => any>(slice: G) => (record: T) => Operator<G>; | ||
readonly sliceEntity: <G extends (record: Draft<T>) => void>(slice: G) => (cb: (operator: Operator<G>) => void) => void; | ||
readonly draft: (drafter: (args: Draft<T>) => void) => void; | ||
} & Extensions]; | ||
export {}; |
@@ -33,5 +33,5 @@ "use strict"; | ||
nextState, | ||
__assign({ entity: entity_1.entity, sliceEntity: function (slice) { return function (record) { return entity_1.entity(slice(record)); }; }, draft: draft }, extensions({ draft: draft, initialState: record, nextState: nextState })) | ||
__assign({ entity: entity_1.entity, sliceEntity: function (slice) { return function (cb) { return draft(function (draft) { return cb(entity_1.entity(slice(draft))); }); }; }, draft: draft }, extensions({ draft: draft, initialState: record, nextState: nextState })) | ||
]; }, [nextState, extensions]); | ||
} | ||
exports.useData = useData; |
{ | ||
"name": "drifting", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "A fully typescript typed react solution for interacting with complex data-structures", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -456,9 +456,6 @@ import { renderHook, act } from '@testing-library/react-hooks' | ||
const recordUser = controller.sliceEntity(record => record.user) | ||
controller.draft(record => { | ||
recordUser(record) | ||
.draft(user => { | ||
user.id = 'altered' | ||
}) | ||
}) | ||
recordUser(operator => operator.draft((user) => { | ||
user.id = 'altered' | ||
})) | ||
}) | ||
@@ -488,4 +485,4 @@ | ||
controller.draft(user => { | ||
recordUserCollection(user) | ||
recordUserCollection((operator) => { | ||
operator | ||
.select((budget) => budget.id === '1') | ||
@@ -492,0 +489,0 @@ .draft(budget => { |
@@ -47,5 +47,5 @@ import { useState, useEffect, useContext, useMemo } from 'react' | ||
entity, | ||
sliceEntity: <G extends (record: T) => any>(slice: G) => ( | ||
record: T | ||
) => entity(slice(record)) as Operator<G>, | ||
sliceEntity: <G extends (record: Draft<T>) => void>(slice: G) => ( | ||
cb: (operator: Operator<G>) => void | ||
) => draft((draft) => cb(entity(slice(draft)) as Operator<G>)), | ||
draft, | ||
@@ -56,1 +56,2 @@ ...extensions({ draft, initialState: record, nextState }), | ||
} | ||
35110
847