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

Working without decorators #3

Open
wants to merge 2 commits into
base: completed-tutorial
Choose a base branch
from

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()
})

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.

None yet

2 participants