Skip to main content

Module: decorators/state

Functions

state

state(target, key, descriptor?): void

Description

@state is used to decorate a class property as a state field.

Example

@injectable()
class Counter {
@state
count = 0;
}

const app = testBed({
modules: [],
main: Counter,
});

expect(app.instance.count).toBe(0);

Parameters

NameType
targetobject
keystring | symbol
descriptor?PropertyDescriptor<any>

Returns

void

Defined in

packages/reactant-module/src/decorators/state.ts:26