Getting started
Installation & Setup​
npm install olik
npm install olik olik-react
import { augmentOlikForReact } from 'olik-react'
augmentOlikForReact() // invoke before initializing store
npm install olik olik-ng
import { OlikNgModule } from 'olik-ng'
@NgModule({ imports: [OlikNgModule] })
export class AppModule {}
npm install olik olik-svelte
import { augmentOlikForSvelte } from 'olik-svelte'
augmentOlikForSvelte() // invoke before initializing store
Creating a store​
Olik supports arbitrarily deep state-trees, however just like with Redux, normalizing your state is still advised.
- With inferred types
- With declared types
import { createStore } from 'olik'
export const store = createStore({
name: document.title, // can be any user-defined string
state: { hello: 'world' } // can be any plain Javascript object
})
import { createStore } from 'olik'
export interface State {
hello: string;
}
export const store = createStore<State>({
name: document.title, // can be any user-defined string
state: { hello: 'world' } // can be any plain Javascript object
})
Integrating with Redux Devtools​
You can integrate with the Redux Devtools by importing the related module before you create your store.
import { importOlikReduxDevtoolsModule } from 'olik'
importOlikReduxDevtoolsModule()