Skip to content

Custom caching function #16

Description

@Splact

I'm working with threejs and here using usePromise to load an external model it works the first time, but not on successive use of the loader on the same resource. Would be nice to have the ability to assign a function that defines the copy logic, with threejs this can be done with mesh.clone(); for example.

This is how the usePromise could work.

  const data = usePromise(
    fetchJson, [
      'https://pokeapi.co/api/v2/pokemon/ditto/',
      { method: 'GET' },
    ],
    {
      // options object instead of single argument for lifespan
      lifespan: 1000,
      onCache: (originalResponse) => myCustomCloneFunction(originalResponse)
    }
);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions