Skip to content

Custom action metadata via decorators #559

@exception-producer

Description

@exception-producer

Hi! First of all thank you for this amazing library, it really is a joy to work with.

We are currently running into a wall when trying to augment the model actions with additional metadata, for example permissions required to execute it. We initially tried simply attaching the metadata to the descriptor, but since mobx-keystone converts these properties to wrappedAction objects internally, this data is lost. We sadly were not able to work around this when experimenting. Since we also do not have access to the model type when setting the decorator, using an external mapping also failed.

We feel like being able to get additional action metadata during runtime would bring a great benefit to this library. All while keeping the clean structure that mobx-keystone provides by also leveraging decorators:

@modelAction
@requirePermissions(['edit'])
setFoo(bar) {
    ...
}

Is there something we may have missed on how to implement this behavior? Thanks!

Metadata

Metadata

Assignees

Labels

🍗 enhancementNew feature or request🎈 releasedA fix that should close the issue has been released👨‍💻 has PRA PR that potentially fixes the issue exists📑 merged to masterFeature done and merged to master

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions