Plain JS Usage
Akita can work with any framework and can be used with plain JS. Here's an example that uses Svelte and Akita functional creation methods:
import { createStore, createQuery } from '@datorama/akita';
export const store = createStore({ count: 0 }, { name: 'counter' });
export const query = createQuery(store);
export const selectCount = query.select('count');
<script>
import { store, selectCount } from './count.state';
function handleClick() {
store.update(state => ({ count: state.count + 1 }));
}
</script>
<button on:click={handleClick}>Clicks: {$selectCount} </button>
For Entity
feature use createEntityStore
and createQueryEntity
functions.
You can read more about it in this article.