0.0.9 • Published 3 years ago

redux-anno v0.0.9

Weekly downloads
88
License
MIT
Repository
github
Last release
3 years ago

npm version Build Status Coverage Status Code style

This is a very early release of this package, do not suggest using it in production till latter stable version

I am a good old fan of spring core context DI and redux-anno is my first try to set up something similar in the Redux World.

A Simple Counter Example showing what I am trying to do

import {Model, State, Saga, createState, initReduxAnno, getContext} from 'redux-anno';

import {putResolve} from 'redux-saga/effects';

@Model()
export class Counter {
  @State
  count = createState(0 as number);

  @Saga()
  *updateCount(nextVal: number) {
    yield putResolve(this.count.create(nextVal));
  }
}

describe('CounterModel', () => {
  beforeAll(() => {
    initReduxAnno({
      entryModel: Counter,
    });
  });

  it('counter 01', async () => {
    const defaultCtx = getContext();
    const counterInst = defaultCtx.getOneInstance(Counter);

    expect(counterInst.count.value).toBe(0);

    await counterInst.updateCount.dispatch(1);

    expect(counterInst.count.value).toBe(1);
  });
});

For more info and details, please check the sample application examples/react-sample-app for now;

More detailed docs are incoming~

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago