type State = number;
enum TYPE{
INCREMENT,
INCREMENT_IF_ODD,
DECREMENT,
INCREMENT_ASYNC
};
interface Creators{
increment(step?: number): { type: string; step: number };
}
interface Selectors{
count: number;
}
interface Options{
step?: number;
getStep?: () => number;
}
export default class MyDuck extends Duck<
State,
typeof TYPE,
Creators,
Selectors,
Options
> {
init() {
super.init();
this.extend(
{
types: TYPE,
...
}
);
}
}
class FooDuck extends Duck {
get quickTypes() {
enum Types {
FOO
}
return {
...super.quickTypes,
...Types
};
}
get rawTypes(){
return {
...super.quickTypes,
FOOO: 'FOOOO'
}
}
get reducers() {
const { types } = this;
return {
...super.reducers,
foo(state = "", action): string {
switch (action.type) {
case types.FOO:
return action.payload;
}
return state;
}
};
}
get creators() {
return {
...super.creators,
foo() {}
};
}
get rawSelectors() {
type State = this["State"];
return {
...super.rawSelectors,
foo(state: State, a: number) {
return state.foo;
}
}
}
*saga() {
yield* super.saga();
this.types.FOO;
this.types.FOOO
this.selector(null).foo;
this.selectors.foo(null, 1);
}
}
class FooDuckMap extends DuckMap {
get reducers() {
return {
...super.reducers,
foo() {
return 1;
}
};
}
get quickDucks() {
return {
...super.quickDucks,
foo1: FooDuck
};
}
get rawDucks(){
return {
...super.rawDucks,
foo2: new FooDuck(this.getSubDuckOptions('foo2'))
}
}
*saga() {
yield* super.saga();
this.State.foo.toExponential;
this.State.foo1.foo.toLowerCase;
this.ducks.foo1.types.FOO;
}
}