anoa
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

Anoa

Anoa React Native SDK

Notice

This project is under development. Not ready for production yet.

Installation

npm i anoa

Usage

Redux Store

Build App Store

import { ReduxStore } from 'anoa'
import { reducers, RootActions, RootState } from './reducers'

export const AppStore = new ReduxStore<RootState, RootActions>(reducers)

Init App Store

Initialize your redux store.

await AppStore.init({
  // redux initial state (optional)
  initialState: {
    todo: {
      foo: 'foo'
    }
  },
  // redux middleware before redux thunk middleware attached (optional)
  beforeMiddleware: [
    awesomeMiddleware,
    anotherMiddleware    
  ],
  // redux middleware before redux thunk middleware attached (optional)
  afterMiddleware: [
    logOrSomethingMiddleware
  ]
})

App Store Provider

Wrap your main component with your store provider.

<AppStore.Provider>
  <View style={styles.container}>
    <Text style={styles.welcome}>Welcome to React Native!</Text>
  </View>
</AppStore.Provider>

App Store Class Decorator

Connect your component to store using withStoreClass class decorator.

@AppStore.withStoreClass<StateProps, ActionProps>(
  state => ({
    foo: state.todo.foo,
    bar: state.todo.bar
  }),
  dispatch => ({
    addFoo: val => dispatch(addFooAction(val))
  })
)
export class Foo extends React.Component<FooProps, FooState> {
  constructor(props: FooProps) {
    super(props)
    this.state = {}
  }

  // ...
}

License

MIT - see LICENSE

Readme

Keywords

none

Package Sidebar

Install

npm i anoa

Weekly Downloads

4

Version

0.0.6

License

MIT

Unpacked Size

12.3 kB

Total Files

8

Last publish

Collaborators

  • budiadiono