data-client

Async State Management without the Management

APACHE-2.0 License

Downloads
44.4K
Stars
1.9K
Committers
37

Bot releases are visible (Hide)

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

  • #3020 dcb6b2f Thanks @ntucker! - Hooks arg-typechecking accuracy improved

    For example string literals now work:

    const getThing = new Endpoint(
      (args: { postId: string | number; sortBy?: "votes" | "recent" }) =>
        Promise.resolve({ a: 5, ...args }),
      { schema: MyEntity },
    );
    
    const myThing = useSuspense(getThing, {
      postId: "5",
      sortBy: "votes",
    });
    
  • #3023 9dea825 Thanks @renovate! - Compatibility with React 19 by removing defaultProps

  • Updated dependencies [9dea825, dcb6b2f]:

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

  • #3017 ce164d2 Thanks @ntucker! - Queries pass-through suspense rather than ever being undefined

    • useSuspense() return values will not be nullable
    • useQuery() will still be nullable due to it handling INVALID as undefined return
    • Query.process does not need to handle nullable cases
data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

  • #3010 c906392 Thanks @ntucker! - ErrorBoundary listens to all errors

    This means it may catch errors that were previously passing thorugh

  • #3010 c906392 Thanks @ntucker! - ErrorBoundary default error fallback supports react native

  • #3010 c906392 Thanks @ntucker! - Add listen prop to ErrorBoundary and AsyncBoundary

    <AsyncBoundary listen={history.listen}>
      <MatchedRoute index={0} />
    </AsyncBoundary>
    
  • #3010 c906392 Thanks @ntucker! - Add resetErrorBoundary sent to errorComponent

    function ErrorComponent({
      error,
      className,
      resetErrorBoundary,
    }: {
      error: Error;
      resetErrorBoundary: () => void;
      className?: string;
    }) {
      return (
        <pre role="alert" className={className}>
          {error.message} <button onClick={resetErrorBoundary}>Reset</button>
        </pre>
      );
    }
    
data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 7 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 7 months ago

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 7 months ago

Release notes and migration guide

Minor Changes

  • #2921 6e55026 Thanks @ntucker! - BREAKING: new AbortOptimistic() -> snapshot.abort

    Before

    getOptimisticResponse(snapshot, { id }) {
      const { data } = snapshot.getResponse(Base.get, { id });
      if (!data) throw new AbortOptimistic();
      return {
        id,
        votes: data.votes + 1,
      };
    }
    

    After

    getOptimisticResponse(snapshot, { id }) {
      const { data } = snapshot.getResponse(Base.get, { id });
      if (!data) throw snapshot.abort;
      return {
        id,
        votes: data.votes + 1,
      };
    }
    
  • #2921 6e55026 Thanks @ntucker! - BREAKING: new Query -> new schema.Query

    Before

    const getUserCount = new Query(
      new schema.All(User),
      (entries, { isAdmin } = {}) => {
        if (isAdmin !== undefined)
          return entries.filter((user) => user.isAdmin === isAdmin).length;
        return entries.length;
      },
    );
    
    const userCount = useCache(getUserCount);
    const adminCount = useCache(getUserCount, { isAdmin: true });
    

    After

    const getUserCount = new schema.Query(
      new schema.All(User),
      (entries, { isAdmin } = {}) => {
        if (isAdmin !== undefined)
          return entries.filter((user) => user.isAdmin === isAdmin).length;
        return entries.length;
      },
    );
    
    const userCount = useQuery(getUserCount);
    const adminCount = useQuery(getUserCount, { isAdmin: true });
    
  • #2957 c129a25 Thanks @ntucker! - BREAKING CHANGE: Remove new AbortOptimistic() in favor of snapshot.abort

    getOptimisticResponse(snapshot, { id }) {
      const { data } = snapshot.getResponse(Base.get, { id });
      if (!data) throw snapshot.abort;
      return {
        id,
        votes: data.votes + 1,
      };
    }
    
  • #2972 bb24601 Thanks @ntucker! - BREAKING: Entity.useIncoming → Entity.shouldUpdate)

    class MyEntity extends Entity {
      // highlight-next-line
      static useIncoming(
        existingMeta: { date: number },
        incomingMeta: { date: number },
        existing: any,
        incoming: any,
      ) {
        return !deepEquals(existing, incoming);
      }
    }
    
    class MyEntity extends Entity {
      // highlight-next-line
      static shouldUpdate(
        existingMeta: { date: number },
        incomingMeta: { date: number },
        existing: any,
        incoming: any,
      ) {
        return !deepEquals(existing, incoming);
      }
    }
    
  • #2921 6e55026 Thanks @ntucker! - BREAKING: useCache(new Index(MyEntity)) -> useQuery(MyEntity)

    Before

    const UserIndex = new Index(User);
    
    const bob = useCache(UserIndex, { username: "bob" });
    

    After

    const bob = useQuery(User, { username: "bob" });
    

Patch Changes

data-client - @data-client/[email protected]

Published by github-actions[bot] 7 months ago

Patch Changes