1.3.1 • Published 3 years ago

@joaomelo/stores v1.3.1

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
3 years ago

stores utils for firebase firestore with optional vue helpers

tr;tl

at the application start desired collections are declared. the library will hold a global store with data and mutation for each one.

this stores are scoped to current user while querying and setting.

the library provide helpers to return reactive computations over one or more of those stores.

getting started

to use it as a vue plugin go with

// index.js
import { stores } from '@joaomelo/stores/vue';
const connection = { ... };
const collections = ['todos', 'notes']
...
app.use(stores, { connection, collections });

// some-component.vue
import { useStores } from '@joaomelo/stores/vue';
const { todos } = useStores(); // <- todos is reactive
...
<div v-for="item in todos.items">
  {{ item.text }}
</div>

if dealing with vanilla js or other frameworks

import { createStores } from '@joaomelo/stores/vue';
const connection = { ... };
const collections = ['todos', 'notes']
const stores = createStores({ connection, collections });

const { todos } = stores;
todos.subscribe((items) => ...)

for each collection you pass it will create a store with:

  • the same collections name
  • items property with an array os the collection records
  • subscribe method to receive updates
  • methods for mutations: set, update and del
1.3.1

3 years ago

1.3.0

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago