Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change definition of meta? #26

Closed
mindjuice opened this issue May 22, 2017 · 3 comments
Closed

Change definition of meta? #26

mindjuice opened this issue May 22, 2017 · 3 comments

Comments

@mindjuice
Copy link

When I try to set a field on meta, TypeScript complains that the property does not exist.

For example:

myAction.meta.requestId = 123

>> Property 'requestId' does not exist on type 'Object'.

The current definition of meta in Action<P> looks like this:

  meta?: Object | null;

If I change it as follows, then I can place any fields into meta with no errors.

  meta?: { [x: string]: any } | null;

Of course this means meta is not type-safe, but it's no worse than the current definition.

Another alternative would be to provide a type parameter for meta (e.g., Action<P,M>), but that might be a bit of overkill for a field like meta.

Any interest in either of these changes?

@aikoven
Copy link
Owner

aikoven commented May 23, 2017

Why do you want to change the meta after your action is created in the first place? I'd rather perceive actions as read-only.

Otherwise, your proposal looks good.

@aikoven
Copy link
Owner

aikoven commented May 23, 2017

Please check out version 2.3.0.

@mindjuice
Copy link
Author

In this case I was looking at having middleware add a requestId and a startTime to the action when it is received by the middleware then sent over the websocket, but I may use a map on requestId as a key instead to keep the actions read only.

Either way, 2.3.0 looks great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants