Async State Management without the Management
APACHE-2.0 License
Bot releases are visible (Hide)
Published by github-actions[bot] 3 months ago
Published by github-actions[bot] 3 months ago
501cb82
Thanks @ntucker! - Remove name in toJSON() for Entities
3058a8a
Thanks @ntucker! - Collection non-known (not Array/Values) key format improvement
Now wraps in parens ()
: "(Todo)"
#3158 34e2e51
Thanks @ntucker! - createResource() -> resource()
Note: createResource
is still exported (it is the same)
Updated dependencies [501cb82
, 501cb82
, 3058a8a
]:
Published by github-actions[bot] 3 months ago
Published by github-actions[bot] 3 months ago
597a1b2
Thanks @ntucker! - Disable devtools dispatch feature as it is not usable
d8666bf
Thanks @ntucker! - Minor store creation optimizations
597a1b2
Thanks @ntucker! - fix: Devtools correctly logs fetch actions
We inspect fetches against inflight to see if they are throttled;
However, we previously did this after we sent the action to NetworkManager, which
meant it would also skip logging any throttlable fetches - even if they were not throttled.
d84b43c
Thanks @ntucker! - Move NetworkManager missing detection to initialization (applyManager())
06df291
Thanks @ntucker! - Reorder action members for easier debuggability
key
at top - easiest to read 'subject'response
or value
after - 'object' being set597a1b2
Thanks @ntucker! - Improve typing for devtools options
Published by github-actions[bot] 3 months ago
597a1b2
Thanks @ntucker! - Disable devtools dispatch feature as it is not usable
597a1b2
Thanks @ntucker! - fix: Devtools correctly logs fetch actions
We inspect fetches against inflight to see if they are throttled;
However, we previously did this after we sent the action to NetworkManager, which
meant it would also skip logging any throttlable fetches - even if they were not throttled.
d84b43c
Thanks @ntucker! - Move NetworkManager missing detection to initialization (applyManager())
06df291
Thanks @ntucker! - Reorder action members for easier debuggability
key
at top - easiest to read 'subject'response
or value
after - 'object' being set597a1b2
Thanks @ntucker! - Improve typing for devtools options
Updated dependencies [597a1b2
, d8666bf
, 597a1b2
, d84b43c
, 06df291
, 597a1b2
]:
Published by github-actions[bot] 3 months ago
Updated dependencies [428d618
]:
Published by github-actions[bot] 3 months ago
#3151 428d618
Thanks @ntucker! - Collection.key is shorter and more readable
[Todo]
for Arrays or {Todo}
for Values
#3151 428d618
Thanks @ntucker! - fix: Collection.key robust against class name mangling
#3151 428d618
Thanks @ntucker! - Collections now work with polymorhpic schemas like Union
Collections.key on polymorphic types lists their possible Entity keys: [PushEvent;PullRequestEvent]
Updated dependencies [428d618
, 428d618
, 428d618
]:
Published by github-actions[bot] 3 months ago
Updated dependencies [7427519
]:
Published by github-actions[bot] 3 months ago
Published by github-actions[bot] 3 months ago
#3151 428d618
Thanks @ntucker! - Collection.key is shorter and more readable
[Todo]
for Arrays or {Todo}
for Values
#3151 428d618
Thanks @ntucker! - fix: Collection.key robust against class name mangling
#3151 428d618
Thanks @ntucker! - Collections now work with polymorhpic schemas like Union
Collections.key on polymorphic types lists their possible Entity keys: [PushEvent;PullRequestEvent]
Published by github-actions[bot] 3 months ago
#3151 428d618
Thanks @ntucker! - Collection.key is shorter and more readable
[Todo]
for Arrays or {Todo}
for Values
#3151 428d618
Thanks @ntucker! - fix: Collection.key robust against class name mangling
#3151 428d618
Thanks @ntucker! - Collections now work with polymorhpic schemas like Union
Collections.key on polymorphic types lists their possible Entity keys: [PushEvent;PullRequestEvent]
Updated dependencies [428d618
, 428d618
, 428d618
]:
Published by github-actions[bot] 3 months ago
#3141 d225595
Thanks @ntucker! - BREAKING CHANGE: setResponseAction.payload -> setResponseAction.response
This only affects those writing custom Managers that
inspect SET_RESPONSE_TYPE
action.payload
.
import {
SET_RESPONSE_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case SET_RESPONSE_TYPE:
console.log('Resolved with value', action.payload);
return next(action);
default:
return next(action);
}
};
cleanup() {}
}
import {
SET_RESPONSE_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case SET_RESPONSE_TYPE:
console.log('Resolved with value', action.response);
return next(action);
default:
return next(action);
}
};
cleanup() {}
}
#3141 d225595
Thanks @ntucker! - BREAKING CHANGE: remove fetchAction.payload
This only affects those writing custom Managers that
inspect FETCH_TYPE
action.fetch
.
import {
FETCH_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case FETCH_TYPE:
// consume fetch, and print the resolution
action.fetch().then(response => console.log(response));
default:
return next(action);
}
};
cleanup() {}
}
import {
FETCH_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case FETCH_TYPE:
// consume fetch, and print the resolution
action
.endpoint(...action.meta.args)
.fetch()
.then(response => console.log(response));
default:
return next(action);
}
};
cleanup() {}
}
#3134 2ad1811
Thanks @ntucker! - Expand peerdep support range to include ^0.14.0
39471f5
Thanks @ntucker! - Add missing types export to @data-client/test/browser
Published by github-actions[bot] 3 months ago
Published by github-actions[bot] 3 months ago
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize visit()
interface; removing non-contextual arguments.
/** Visits next data + schema while recurisvely normalizing */
export interface Visit {
(schema: any, value: any, parent: any, key: any, args: readonly any[]): any;
creating?: boolean;
}
This results in a 10% normalize performance boost.
processedEntity[key] = visit(
processedEntity[key],
processedEntity,
key,
this.schema[key],
addEntity,
visitedEntities,
storeEntities,
args,
);
processedEntity[key] = visit(
this.schema[key],
processedEntity[key],
processedEntity,
key,
args,
);
The information needed from these arguments are provided by closing visit()
around them.
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize interface from direct data access, to using functions like getEntity
interface SchemaSimple {
normalize(
input: any,
parent: any,
key: any,
args: any[],
visit: (
schema: any,
value: any,
parent: any,
key: any,
args: readonly any[],
) => any,
addEntity: (...args: any) => any,
getEntity: (...args: any) => any,
checkLoop: (...args: any) => any,
): any;
}
We also add checkLoop()
, which moves some logic in Entity
to the core normalize algorithm.
/** Returns true if a circular reference is found */
export interface CheckLoop {
(entityKey: string, pk: string, input: object): boolean;
}
#3134 2ad1811
Thanks @ntucker! - Change Schema.denormalize unvisit
to have schema argument first.
interface SchemaSimple {
denormalize(
input: {},
args: readonly any[],
unvisit: (schema: any, input: any) => any,
): T;
}
2ad1811
, 2ad1811
, 2ad1811
, 7bd322d
]:
Published by github-actions[bot] 3 months ago
#3146 6325384
Thanks @ntucker! - Call fetches immediately - do not wait for idle
NetworkManager will fetch
immediately, rather than waiting for idle. With React 18+ it is expected for
React to better handle work with concurrent mode and batching. Due to this, it
is not longer deemed the best performance to wait for idle and instead we should
fetch immediately.
IdlingNetworkManager
is still available to keep the previous behavior.
#3141 d225595
Thanks @ntucker! - BREAKING CHANGE: setResponseAction.payload -> setResponseAction.response
This only affects those writing custom Managers that
inspect SET_RESPONSE_TYPE
action.payload
.
import {
SET_RESPONSE_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case SET_RESPONSE_TYPE:
console.log('Resolved with value', action.payload);
return next(action);
default:
return next(action);
}
};
cleanup() {}
}
import {
SET_RESPONSE_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case SET_RESPONSE_TYPE:
console.log('Resolved with value', action.response);
return next(action);
default:
return next(action);
}
};
cleanup() {}
}
#3143 f4cf8a4
Thanks @ntucker! - action.meta.args -> action.args
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize visit()
interface; removing non-contextual arguments.
/** Visits next data + schema while recurisvely normalizing */
export interface Visit {
(schema: any, value: any, parent: any, key: any, args: readonly any[]): any;
creating?: boolean;
}
This results in a 10% normalize performance boost.
processedEntity[key] = visit(
processedEntity[key],
processedEntity,
key,
this.schema[key],
addEntity,
visitedEntities,
storeEntities,
args,
);
processedEntity[key] = visit(
this.schema[key],
processedEntity[key],
processedEntity,
key,
args,
);
The information needed from these arguments are provided by closing visit()
around them.
#3141 d225595
Thanks @ntucker! - BREAKING CHANGE: remove fetchAction.payload
This only affects those writing custom Managers that
inspect FETCH_TYPE
action.fetch
.
import {
FETCH_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case FETCH_TYPE:
// consume fetch, and print the resolution
action.fetch().then(response => console.log(response));
default:
return next(action);
}
};
cleanup() {}
}
import {
FETCH_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case FETCH_TYPE:
// consume fetch, and print the resolution
action
.endpoint(...action.meta.args)
.fetch()
.then(response => console.log(response));
default:
return next(action);
}
};
cleanup() {}
}
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize interface from direct data access, to using functions like getEntity
interface SchemaSimple {
normalize(
input: any,
parent: any,
key: any,
args: any[],
visit: (
schema: any,
value: any,
parent: any,
key: any,
args: readonly any[],
) => any,
addEntity: (...args: any) => any,
getEntity: (...args: any) => any,
checkLoop: (...args: any) => any,
): any;
}
We also add checkLoop()
, which moves some logic in Entity
to the core normalize algorithm.
/** Returns true if a circular reference is found */
export interface CheckLoop {
(entityKey: string, pk: string, input: object): boolean;
}
#3134 2ad1811
Thanks @ntucker! - Change Schema.denormalize unvisit
to have schema argument first.
interface SchemaSimple {
denormalize(
input: {},
args: readonly any[],
unvisit: (schema: any, input: any) => any,
): T;
}
8aabe18
Thanks @ntucker! - More robust requestIdleCallback wrapper
#3143 f4cf8a4
Thanks @ntucker! - action.meta.key -> action.key
#3139 9df0f7c
Thanks @ntucker! - Get rid of fetch action.meta.nm. This is not used anywhere.
Updated dependencies [d225595
, 96f7eb0
, 3ffa454
, ee509fb
, f4cf8a4
, f4cf8a4
, 2ad1811
, d225595
, 2ad1811
, 2ad1811
, f4cf8a4
, 9df0f7c
]:
Published by github-actions[bot] 3 months ago
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize visit()
interface; removing non-contextual arguments.
/** Visits next data + schema while recurisvely normalizing */
export interface Visit {
(schema: any, value: any, parent: any, key: any, args: readonly any[]): any;
creating?: boolean;
}
This results in a 10% normalize performance boost.
processedEntity[key] = visit(
processedEntity[key],
processedEntity,
key,
this.schema[key],
addEntity,
visitedEntities,
storeEntities,
args,
);
processedEntity[key] = visit(
this.schema[key],
processedEntity[key],
processedEntity,
key,
args,
);
The information needed from these arguments are provided by closing visit()
around them.
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize interface from direct data access, to using functions like getEntity
interface SchemaSimple {
normalize(
input: any,
parent: any,
key: any,
args: any[],
visit: (
schema: any,
value: any,
parent: any,
key: any,
args: readonly any[],
) => any,
addEntity: (...args: any) => any,
getEntity: (...args: any) => any,
checkLoop: (...args: any) => any,
): any;
}
We also add checkLoop()
, which moves some logic in Entity
to the core normalize algorithm.
/** Returns true if a circular reference is found */
export interface CheckLoop {
(entityKey: string, pk: string, input: object): boolean;
}
#3134 2ad1811
Thanks @ntucker! - Change Schema.denormalize unvisit
to have schema argument first.
interface SchemaSimple {
denormalize(
input: {},
args: readonly any[],
unvisit: (schema: any, input: any) => any,
): T;
}
#3134 2ad1811
Thanks @ntucker! - Change normalize() interface
function normalize(
schema,
input,
args,
{ entities, indexes, entityMeta },
{ date, expiresAt, fetchedAt },
);
const { result, entities, indexes, entityMeta } = normalize(
action.endpoint.schema,
payload,
action.args,
state,
action.meta,
);
#3134 2ad1811
Thanks @ntucker! - Change denormalize() interface
function denormalize(schema, input, entities, args);
const value = denormalize(endpoint.schema, input, state.entities, args);
#3134 2ad1811
Thanks @ntucker! - Change MemoCache methods interface
class MemoCache {
denormalize(schema, input, entities, args): { data; paths };
query(schema, args, entities, indexes): data;
buildQueryKey(schema, args, entities, indexes): normalized;
}
Published by github-actions[bot] 3 months ago
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize visit()
interface; removing non-contextual arguments.
/** Visits next data + schema while recurisvely normalizing */
export interface Visit {
(schema: any, value: any, parent: any, key: any, args: readonly any[]): any;
creating?: boolean;
}
This results in a 10% normalize performance boost.
processedEntity[key] = visit(
processedEntity[key],
processedEntity,
key,
this.schema[key],
addEntity,
visitedEntities,
storeEntities,
args,
);
processedEntity[key] = visit(
this.schema[key],
processedEntity[key],
processedEntity,
key,
args,
);
The information needed from these arguments are provided by closing visit()
around them.
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize interface from direct data access, to using functions like getEntity
interface SchemaSimple {
normalize(
input: any,
parent: any,
key: any,
args: any[],
visit: (
schema: any,
value: any,
parent: any,
key: any,
args: readonly any[],
) => any,
addEntity: (...args: any) => any,
getEntity: (...args: any) => any,
checkLoop: (...args: any) => any,
): any;
}
We also add checkLoop()
, which moves some logic in Entity
to the core normalize algorithm.
/** Returns true if a circular reference is found */
export interface CheckLoop {
(entityKey: string, pk: string, input: object): boolean;
}
#3134 2ad1811
Thanks @ntucker! - Change Schema.denormalize unvisit
to have schema argument first.
interface SchemaSimple {
denormalize(
input: {},
args: readonly any[],
unvisit: (schema: any, input: any) => any,
): T;
}
2ad1811
, 2ad1811
, 2ad1811
, 7bd322d
]:
Published by github-actions[bot] 3 months ago
Published by github-actions[bot] 3 months ago
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize visit()
interface; removing non-contextual arguments.
/** Visits next data + schema while recurisvely normalizing */
export interface Visit {
(schema: any, value: any, parent: any, key: any, args: readonly any[]): any;
creating?: boolean;
}
This results in a 10% normalize performance boost.
processedEntity[key] = visit(
processedEntity[key],
processedEntity,
key,
this.schema[key],
addEntity,
visitedEntities,
storeEntities,
args,
);
processedEntity[key] = visit(
this.schema[key],
processedEntity[key],
processedEntity,
key,
args,
);
The information needed from these arguments are provided by closing visit()
around them.
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize interface from direct data access, to using functions like getEntity
interface SchemaSimple {
normalize(
input: any,
parent: any,
key: any,
args: any[],
visit: (
schema: any,
value: any,
parent: any,
key: any,
args: readonly any[],
) => any,
addEntity: (...args: any) => any,
getEntity: (...args: any) => any,
checkLoop: (...args: any) => any,
): any;
}
We also add checkLoop()
, which moves some logic in Entity
to the core normalize algorithm.
/** Returns true if a circular reference is found */
export interface CheckLoop {
(entityKey: string, pk: string, input: object): boolean;
}
#3134 2ad1811
Thanks @ntucker! - Change Schema.denormalize unvisit
to have schema argument first.
interface SchemaSimple {
denormalize(
input: {},
args: readonly any[],
unvisit: (schema: any, input: any) => any,
): T;
}
#3133 7bd322d
Thanks @ntucker! - Validate after marking cirucular reference loops
This should not change any behavior as validate should be deterministic so if it fails
it will fail again and failure measure throwing which exits the whole stack.
This improves code grouping. (And possibly cache locality improvement - though didn't check.)
Published by github-actions[bot] 3 months ago
#3141 d225595
Thanks @ntucker! - BREAKING CHANGE: setResponseAction.payload -> setResponseAction.response
This only affects those writing custom Managers that
inspect SET_RESPONSE_TYPE
action.payload
.
import {
SET_RESPONSE_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case SET_RESPONSE_TYPE:
console.log('Resolved with value', action.payload);
return next(action);
default:
return next(action);
}
};
cleanup() {}
}
import {
SET_RESPONSE_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case SET_RESPONSE_TYPE:
console.log('Resolved with value', action.response);
return next(action);
default:
return next(action);
}
};
cleanup() {}
}
96f7eb0
Thanks @ntucker! - Renamed FETCH action.meta.createdAt to fetchedAt to be consistent with other actions like
SET_RESPONSE.
BREAKING CHANGE: fetchAction.meta.createdAt -> fetchAction.meta.fetchedAt
#3138 ee509fb
Thanks @ntucker! - Remove throttle from FETCH_TYPE action
BREAKING CHANGE: action.meta.throttle -> !action.endpoint.sideEffect
#3143 f4cf8a4
Thanks @ntucker! - action.meta.args -> action.args
#3143 f4cf8a4
Thanks @ntucker! - Add actions
export
actions
is a namespace for all action creators. It is typically
preferred to use Controller's type-safe dispatch methods, as
members of this namespace could have breaking changes in a minor release.
import { actions, type Manager, type Middleware } from '@data-client/core';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => {
const todo = { id: '5', title: 'my first todo' };
// These do the same thing
controller.dispatch(
actions.createSet(Todo, { args: [{ id: todo.id }], value: todo }),
);
// This is simpler; type-enforced; and will only change in major versions
controller.set(Todo, { id: todo.id }, todo);
return async action => next(action);
};
cleanup() {}
}
BREAKING CHANGE: Removed createFetch
, createSet
, createSetResponse
from export. Use action.createFetch instead.
#3141 d225595
Thanks @ntucker! - BREAKING CHANGE: remove fetchAction.payload
This only affects those writing custom Managers that
inspect FETCH_TYPE
action.fetch
.
import {
FETCH_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case FETCH_TYPE:
// consume fetch, and print the resolution
action.fetch().then(response => console.log(response));
default:
return next(action);
}
};
cleanup() {}
}
import {
FETCH_TYPE,
type Manager,
type Middleware,
} from '@data-client/react';
export default class MyManager implements Manager {
getMiddleware = (): Middleware => controller => next => async action => {
switch (action.type) {
case FETCH_TYPE:
// consume fetch, and print the resolution
action
.endpoint(...action.meta.args)
.fetch()
.then(response => console.log(response));
default:
return next(action);
}
};
cleanup() {}
}
#3143 f4cf8a4
Thanks @ntucker! - action.meta.key -> action.key
#3139 9df0f7c
Thanks @ntucker! - Get rid of fetch action.meta.nm. This is not used anywhere.
3ffa454
Thanks @ntucker! - internal: Simplify fetchReducer code
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize visit()
interface; removing non-contextual arguments.
/** Visits next data + schema while recurisvely normalizing */
export interface Visit {
(schema: any, value: any, parent: any, key: any, args: readonly any[]): any;
creating?: boolean;
}
This results in a 10% normalize performance boost.
processedEntity[key] = visit(
processedEntity[key],
processedEntity,
key,
this.schema[key],
addEntity,
visitedEntities,
storeEntities,
args,
);
processedEntity[key] = visit(
this.schema[key],
processedEntity[key],
processedEntity,
key,
args,
);
The information needed from these arguments are provided by closing visit()
around them.
#3134 2ad1811
Thanks @ntucker! - Change Schema.normalize interface from direct data access, to using functions like getEntity
interface SchemaSimple {
normalize(
input: any,
parent: any,
key: any,
args: any[],
visit: (
schema: any,
value: any,
parent: any,
key: any,
args: readonly any[],
) => any,
addEntity: (...args: any) => any,
getEntity: (...args: any) => any,
checkLoop: (...args: any) => any,
): any;
}
We also add checkLoop()
, which moves some logic in Entity
to the core normalize algorithm.
/** Returns true if a circular reference is found */
export interface CheckLoop {
(entityKey: string, pk: string, input: object): boolean;
}
#3134 2ad1811
Thanks @ntucker! - Change Schema.denormalize unvisit
to have schema argument first.
interface SchemaSimple {
denormalize(
input: {},
args: readonly any[],
unvisit: (schema: any, input: any) => any,
): T;
}
Updated dependencies [2ad1811
, 2ad1811
, 2ad1811
, 2ad1811
, 2ad1811
, 2ad1811
]: