Skip to content

Latest commit

 

History

History
278 lines (183 loc) · 10.4 KB

File metadata and controls

278 lines (183 loc) · 10.4 KB

@tanstack/react-db

0.0.22

Patch Changes

  • Updated dependencies [aeee9a1]:
    • @tanstack/db@0.0.22

0.0.21

Patch Changes

  • Updated dependencies [8e23322]:
    • @tanstack/db@0.0.21

0.0.20

Patch Changes

  • Updated dependencies [f13c11e]:
    • @tanstack/db@0.0.20

0.0.19

Patch Changes

  • Updated dependencies [9f0b0c2]:
    • @tanstack/db@0.0.19

0.0.18

Patch Changes

  • Improve jsdocs (#243)

  • Updated dependencies [266bd29]:

    • @tanstack/db@0.0.18

0.0.17

Patch Changes

  • Updated dependencies [7e63d76]:
    • @tanstack/db@0.0.17

0.0.16

Patch Changes

  • add support for composable queries (#232)

  • Updated dependencies [e478d53]:

    • @tanstack/db@0.0.16

0.0.15

Patch Changes

0.0.14

Patch Changes

  • Updated dependencies [74c140d]:
    • @tanstack/db@0.0.14

0.0.13

Patch Changes

  • feat: implement Collection Lifecycle Management (#198)

    Adds automatic lifecycle management for collections to optimize resource usage.

    New Features:

    • Added startSync option (defaults to false, set to true to start syncing immediately)
    • Automatic garbage collection after gcTime (default 5 minutes) of inactivity
    • Collection status tracking: "idle" | "loading" | "ready" | "error" | "cleaned-up"
    • Manual preload() and cleanup() methods for lifecycle control

    Usage:

    const collection = createCollection({
      startSync: false, // Enable lazy loading
      gcTime: 300000, // Cleanup timeout (default: 5 minutes)
    })
    
    console.log(collection.status) // Current state
    await collection.preload() // Ensure ready
    await collection.cleanup() // Manual cleanup
  • Add createOptimisticAction helper that replaces useOptimisticMutation (#210)

    An example of converting a useOptimisticMutation hook to createOptimisticAction. Now all optimistic & server mutation logic are consolidated.

    -import { useOptimisticMutation } from '@tanstack/react-db'
    +import { createOptimisticAction } from '@tanstack/react-db'
    +
    +// Create the `addTodo` action, passing in your `mutationFn` and `onMutate`.
    +const addTodo = createOptimisticAction<string>({
    +  onMutate: (text) => {
    +    // Instantly applies the local optimistic state.
    +    todoCollection.insert({
    +      id: uuid(),
    +      text,
    +      completed: false
    +    })
    +  },
    +  mutationFn: async (text) => {
    +    // Persist the todo to your backend
    +    const response = await fetch('/api/todos', {
    +      method: 'POST',
    +      body: JSON.stringify({ text, completed: false }),
    +    })
    +    return response.json()
    +  }
    +})
    
     const Todo = () => {
    -  // Create the `addTodo` mutator, passing in your `mutationFn`.
    -  const addTodo = useOptimisticMutation({ mutationFn })
    -
       const handleClick = () => {
    -    // Triggers the mutationFn
    -    addTodo.mutate(() =>
    -      // Instantly applies the local optimistic state.
    -      todoCollection.insert({
    -        id: uuid(),
    -        text: '🔥 Make app faster',
    -        completed: false
    -      })
    -    )
    +    // Triggers the onMutate and then the mutationFn
    +    addTodo('🔥 Make app faster')
       }
    
       return <Button onClick={ handleClick } />
     }
  • Updated dependencies [945868e, 0f8a008, 57b5f5d]:

    • @tanstack/db@0.0.13

0.0.12

Patch Changes

  • Updated dependencies [f6abe9b]:
    • @tanstack/db@0.0.12

0.0.11

Patch Changes

  • Export ElectricCollectionUtils & allow passing generic to createTransaction (#179)

  • Updated dependencies [66ed58b, c5489ff]:

    • @tanstack/db@0.0.11

0.0.10

Patch Changes

  • Updated dependencies [38d4505]:
    • @tanstack/db@0.0.10

0.0.9

Patch Changes

  • Updated dependencies [2ae0b09]:
    • @tanstack/db@0.0.9

0.0.8

Patch Changes

  • A large refactor of the core Collection with: (#155)

    • a change to not use Store internally and emit fine grade changes with subscribeChanges and subscribeKeyChanges methods.
    • changes to the Collection api to be more Map like for reads, with get, has, size, entries, keys, and values.
    • renames config.getId to config.getKey for consistency with the Map like api.
  • Updated dependencies [5c538cf, 9553366, b4602a0, 02adc81, 06d8ecc, c50cd51]:

    • @tanstack/db@0.0.8

0.0.7

Patch Changes

  • Expose utilities on collection instances (#161)

    Implemented a utility exposure pattern for TanStack DB collections that allows utility functions to be passed as part of collection options and exposes them under a .utils namespace, with full TypeScript typing.

    • Refactored createCollection in packages/db/src/collection.ts to accept options with utilities directly
    • Added utils property to CollectionImpl
    • Added TypeScript types for utility functions and utility records
    • Changed Collection from a class to a type, updating all usages to use createCollection() instead
    • Updated Electric/Query implementations
    • Utilities are now ergonomically accessible under .utils
    • Full TypeScript typing is preserved for both collection data and utilities
    • API is clean and straightforward - users can call createCollection(optionsCreator(config)) directly
    • Zero-boilerplate TypeScript pattern that infers utility types automatically
  • Updated dependencies [8b43ad3]:

    • @tanstack/db@0.0.7

0.0.6

Patch Changes

0.0.5

Patch Changes

  • Collections must have a getId function & use an id for update/delete operators (#134)

  • the keyBy query operator has been removed, keying withing the query pipeline is now automatic (#144)

  • Updated dependencies [1fbb844, 338efc2, ee5d026, e7b036c, e4feb0c]:

    • @tanstack/db@0.0.5

0.0.4

Patch Changes

  • Updated dependencies [8ce449e]:
    • @tanstack/db@0.0.4

0.0.3

Patch Changes

  • Updated dependencies [b29420b]:
    • @tanstack/db@0.0.3

0.0.2

Patch Changes

  • Fixed an issue with injecting the optimistic state removal into the reactive live query. (#78)

  • Updated dependencies [4c82edb]:

    • @tanstack/db@0.0.2

0.0.3

Patch Changes

  • Make transactions first class & move ownership of mutationFn from collections to transactions (#53)

  • Updated dependencies [b42479c]:

    • @tanstack/db@0.0.3

0.0.2

Patch Changes

  • make mutationFn optional for read-only collections (#12)

  • Updated dependencies [9bb6e89, 8eb7e9b]:

    • @tanstack/db@0.0.2

0.0.1

Patch Changes

  • feat: Initial release (#2)

  • Updated dependencies [2d2dd77]:

    • @tanstack/db@0.0.1