Skip to content

delashum/vncache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8077cc7 · Sep 10, 2023

History

11 Commits
Sep 10, 2023
Sep 10, 2023
Feb 16, 2023
Feb 17, 2023
Feb 16, 2023
Feb 17, 2023
Sep 10, 2023
Sep 10, 2023
Sep 10, 2023
Sep 10, 2023
Feb 17, 2023
Feb 22, 2023

Repository files navigation

vncache (very nice cache)

a library to manage state and caching for remote resources with a REST-like backend.

getting started

// cache.ts
import {resource, createResourceCache} from '@delashum/vncache'

type Task = {
  id: string
  name: string
  completed: boolean
}

const tasksResource = resource<Task>(async () => {
  const tasks = await fetchTasksFromBackend()
  return tasks
})

const $cache = createResourceCache({
  tasks: tasksResource,
})
// App.tsx
import {$cache} from './cache.ts'

const App = () => {
  const tasks = $cache.tasks.use()

  return (
    <div>
      {tasks.map(t => (
        <div>{t.name}</div>
      ))}
    </div>
  )
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published