Skip to content

v0.16.0-beta.14

Pre-release
Pre-release
Compare
Choose a tag to compare
@puppybits puppybits released this 11 Jun 17:07
· 64 commits to master since this release
9ccfc13

v0.16.0 - Turn on Immediate Mode for the UI

  • Cache Reducer. UI feels instantaneous to users.
    • Enables optimistic updates for new, deleted & updated data.
    • All data changes synchronously reflected in the redux state cache reducer queries.
    • Once Firestore approves/rejects a change it also removes the optimistic commit.
// selector for cache reducer
(state) => state.firebase.firestore.cache[myStoreAs].docs;

// access read-only fragment of Firestore based on all active queries
const document = state.firebase.firestore.cache.database[full_path_to_collection][document_id];
  • Mutate. Simplifies saving, batching and transactions.
    • Easily switch between single saves and atomic transactions.
    • Simplifies complex saves that have to coordinate through multiple actions.
    • Synchronously updates queries in the cache reducer for instance UI feedback for the app.
// single save
getFirestore().mutate({collection: 'tasks', doc: 'task-1', data: {status: 2}});
// batch
getFirestore().mutate([
  {collection: 'tasks', doc: 'task-1', data: {status: 2}},
  {collection: 'tasks', doc: 'task-2', data: {status: 2}},
]);
// transaction, read results use dependency injection for write functions.
getFirestore().mutate({
  reads: { task1: {collection: 'tasks', doc: 'task-1'} },
  writes: [ ({task1}) => ({collection: 'tasks', doc: task1.id, data: { status: task1.status +1 })) ]
});