rd-url-utils
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

defineAction

defineAction<TActionData> - allows to define a simple action creator which produces actions with specified props.

const MyAction = defineAction<{ value: number; }>("MY ACTION");

Now action creator could be used for creating actions:

const actionInstance = MyAction({ value: 123 });
console.log(actionInstance.value); // Outputs 123

Also action creator could be used for checking actions for conforming a type:

const action: Action = ...
if (MyAction.is(action)) {
    console.log(action.value); // action variable type now shrinked to { type: string; value: number }
}

Readme

Keywords

none

Package Sidebar

Install

npm i rd-url-utils

Weekly Downloads

5

Version

1.1.1

License

MIT

Unpacked Size

21.9 kB

Total Files

17

Last publish

Collaborators

  • rd-dev