1.0.0-alpha.4 • Published 7 years ago
react-workerdb v1.0.0-alpha.4
react-workerdb
React bindings for workerdb
Install
Yarn
yarn add workerdb react-workerdb
NPM
npm i workerdb react-workerdb
How to Use
React
You need to wrap your app with the WorkerDB
provider. You may then use Find
, FindOne
and Database
components.
import { WorkerDB, Find, FindOne, Collection } from 'react-workerdb';
const worker = new Worker('./worker.js');
export default () => (
<WorkerDB worker={worker} loading={() => 'Is loading ...'}>
<div>
<Collection
name="bird"
render={collection => (
<button onClick={() => collection.insert({ name: 'Filou' })}>
Add Bird
</button>
)}
/>
<Collection
name="bird"
render={collection => (
<button
onClick={() => collection.upsert({ _id: '123', name: 'Filou' })}
>
Update bird
</button>
)}
/>
<Collection
name="bird"
render={collection => (
<button onClick={() => collection.remove({ _id: '123' })}>
Delete bird
</button>
)}
/>
<Find
live
collection="bird"
render={docs => <span>There is {docs.length} birds</span>}
/>
<FindOne
live
collection="bird"
id="123"
render={docs => <span>There is {docs.length} birds</span>}
/>
<Find
live
collection="bird"
name={{ $regex: /f/i }}
render={docs => <span>There is {docs.length} birds</span>}
/>
</div>
</WorkerDB>
);
1.0.0-alpha.4
7 years ago
1.0.0-alpha.3
7 years ago
1.0.0-alpha.2
7 years ago
1.0.0-alpha.1
7 years ago
1.0.0-alpha.0
7 years ago
0.5.0
7 years ago
0.4.4
7 years ago
0.4.3
7 years ago
0.4.2
7 years ago
0.3.0
7 years ago
0.2.3
7 years ago
0.2.1
7 years ago
0.2.0
7 years ago
0.1.0
7 years ago
0.0.16
7 years ago
0.0.15
7 years ago
0.0.14
7 years ago
0.0.13
7 years ago
0.0.12
7 years ago
0.0.10
7 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.6
7 years ago
0.0.5
7 years ago
0.0.4
7 years ago
0.0.3
7 years ago
0.0.2
7 years ago