1.0.4 • Published 8 months ago

@delashum/vncache v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

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>
  )
}
1.0.4

8 months ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago