blaze-forms icon indicating copy to clipboard operation
blaze-forms copied to clipboard

Template onCreated before templates:forms package

Open paulbalomiri opened this issue 9 years ago • 4 comments

Hi, I think there is no clean way to install a created (or any other) hook before createFactory is called. I thought about a PR, but in any way i think of it it's not backward compatible.

  • Use case: a template producing action,schema and data arguments from some collection and id template arguments.

Workaround for onCreated:

Template.form.onCreated ->
  ## some custom init
reactiveForms.createFormBlock
    template: 'form'
    submitType: 'normal'
Template.form.onCreated Template.created
delete Template.form.created

Is there any chance for the future to switch to using onCreate at register time, and announce the breaking chage?

paulbalomiri avatar Mar 14 '16 16:03 paulbalomiri

I'm confused about what you are trying to accomplish here. All you need to do to run your own created callback before the package's created callback is call onCreated before you register the template.

jonjamz avatar Mar 14 '16 21:03 jonjamz

Yes, i'm creating a lib, and want to be able to pass collection and id instead of schema and action. In module.js Line 1360 and 1426 this package uses the deprecated template.created callback setter which runs before any onCreated callbacks.

So even when installing an onCreated callback before ReactiveForms.create(Formblock|Element) it is run only after the templates:forms callback.

paulbalomiri avatar Mar 15 '16 05:03 paulbalomiri

Ah. I thought I fixed that a long time ago. I guess I forgot!

I will publish an update soon with this fix.

jonjamz avatar Mar 15 '16 10:03 jonjamz

Just reminding you that this is a breaking change though :smile:.

paulbalomiri avatar Mar 15 '16 14:03 paulbalomiri