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

Consider support for custom “updaters” in default template engine. #132

Open
theengineear opened this issue Mar 4, 2023 · 0 comments

Comments

@theengineear
Copy link
Collaborator

Just adding this for completeness. We likely have no need to expose custom updaters in our default templating engine, but if we ever wanted to, it could look something like this:

  static updater(update, transform) {
    return (value, ...args) => {
      const reference = Template.#createReference();
      const context = transform?.(...args);
      const updater = (type, lastValue, details) => {
        update(type, value, lastValue, details, context);
      };
      Template.#updaters.set(reference, { updater, value });
      return reference;
    };
  }

While it's not much of a code burden — it does pose an interface burden that might be hard to change in the future. IFF we really needed this, we could always add (harder to remove later than it is to add later).

Also note that other templating engines expose custom functionality like this — so it's possible to simply plug something else in if needed.

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