Pullstate

Pullstate

  • Docs
  • GitHub

›Async Actions

Getting Started

  • Installation
  • Quick example
  • Quick example (server rendering)

Reading Store State

  • useStoreState (hook)
  • <InjectStoreState>
  • Subscribe

Updating Store State

  • update()
  • Reactions

Async Actions

  • Introduction
  • Creating an Async Action
  • Use Async Actions
  • Async Action Hooks

    • Hooks overview
    • Post action hook
    • Short circuit hook
    • Cache break hook
  • Other Async Action Options
  • Cache clearing
  • Resolve async state on the server

Dev Tools

  • Redux Devtools

Async cache clearing

A big part of working with asynchronous data is being able to control the cache.

There's even a famous quote for it:

"There are only two hard things in Computer Science: cache invalidation and naming things."

-Phil Karlton

To try and make at least one of those things a bit easier for you, Pullstate provides a few different ways of dealing with cache invalidation with your async actions.

Direct cache invalidation

There are three "direct" ways to invalidate the cache for an action:

Clear the cache for specific arguments (fingerprint)

See more

GetUserAction.clearCache({ userId });

Clear the cache completely for an action (all combinations of arguments)

See more

GetUserAction.clearAllCache();

Clear all unwatched cache for an action

See more

GetUserAction.clearAllUnwatchedCache();

Conditional cache invalidation

There is also a way to check and clear the cache automatically, using something called a cacheBreakHook - which runs when an action is called which already has a cached result, and decides whether the current cached result is still worthy. Check out the async hooks flow diagram to better understand how this hook fits in.

Cache Break Hook

cacheBreakHook: ({ result, args, timeCached }) => true | false
← Other Async Action OptionsResolve async state on the server →
  • Direct cache invalidation
    • Clear the cache for specific arguments (fingerprint)
    • Clear the cache completely for an action (all combinations of arguments)
    • Clear all unwatched cache for an action
  • Conditional cache invalidation
    • Cache Break Hook
Pullstate
Docs
InstallationA Quick ExampleMore
Community
GitHub
Pullstate
Created by Paul Myburgh