Skip to content

Working without decorators#3

Open
noam-honig wants to merge 2 commits intocompleted-tutorialfrom
working-without-decorators
Open

Working without decorators#3
noam-honig wants to merge 2 commits intocompleted-tutorialfrom
working-without-decorators

Conversation

@noam-honig
Copy link
Contributor

Demonstrate how one can work without decorators with remult

Comment on lines +10 to +22
describeClass(Task, Entity<Task>("tasks", {
allowApiRead: Allow.authenticated,
allowApiUpdate: Allow.authenticated,
allowApiInsert: Roles.admin,
allowApiDelete: Roles.admin
}), {
id: Fields.uuid(),
title: Fields.string({
validate: Validators.required,
allowApiUpdate: Roles.admin
}),
completed: Fields.boolean()
}) No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks equivalent to the decorators version. 2 questions:

  1. If I have a typo anywhere, does TS catch that and let me know? If no, then does at least the runtime catch it?
  2. Have you looked into the mobx way of decorating classes without decorators (in the ctor)? I'm assuming they carefully evaluated different approaches and that their chosen one was found superior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - Answers:

  1. Yes - typescript will let you know there is an error and search references work.
  2. Mobx needed something other than me - All I need is some metadata - mobx needed to alter the class instance itself - that's why they used the "makeAutoObservable" in the constructor and changed the members to properties.

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

Successfully merging this pull request may close these issues.

2 participants