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

Tweak setDefaults API #1024

Open
stephenh opened this issue Apr 8, 2024 · 0 comments
Open

Tweak setDefaults API #1024

stephenh opened this issue Apr 8, 2024 · 0 comments

Comments

@stephenh
Copy link
Collaborator

stephenh commented Apr 8, 2024

We should separate:

  • "sync defaults" that are set immediately on em.create, from
  • "async defaults" that only run on em.flush

We should allow a sync default that can read other FKs, i.e.:

/** Ensure that the iti has an originalIti set on creation */
config.beforeCreate((iti) => {
  if (!iti.original.isSet) {
    iti.original.set(iti);
  }
});

To:

config.setDefault("original", iti => iti.original.get ?? iti);
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

1 participant