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

Not possible to stack plugins #17

Open
mitar opened this issue Dec 18, 2014 · 8 comments
Open

Not possible to stack plugins #17

mitar opened this issue Dec 18, 2014 · 8 comments

Comments

@mitar
Copy link
Contributor

mitar commented Dec 18, 2014

It is not possible to stack plugins. The inner one wins currently.

@tmeasday
Copy link
Member

What use case do you have in mind @mitar ?

@mitar
Copy link
Contributor Author

mitar commented Dec 22, 2014

I had this plugin. And I wanted to combine it with slide-height plugin:

{{#momentum plugin='slide-height'}}
  {{#momentum plugin='keep-visible'}}
    ...
  {{/momentum}}
{{/momentum}}

But it does not work. :-(

So now I had to manually merged it into one. Not good for code reuse.

@tmeasday
Copy link
Member

How would it work though? The plugin is responsible for actually inserting/removing the element.

I think we'd need a different API in order for composing plugins to make sense. My guess is such a fully featured package is different from momentum (or extends on momentum), which is intended to be pretty close to the _uihooks metal.

@mitar
Copy link
Contributor Author

mitar commented Dec 22, 2014

I have no idea how this would work. :-) I am just opening it here because for end programmers it would be amazing if it would work out of the box.

But don't most plugins call insert/remove at the end? This could be replaced with call to done() and done() would then do it? From what I am seeing we often mostly want to do some things before and after the insert, but at the end we do insert.

One other options is to make plugins themselves extendable. I am doing this through CoffeeScript classes for my plugins. Then one could extend the class, and call super to get parent action. But this is still not custom stacking.

@tmeasday
Copy link
Member

Yeah, I was thinking the same thing. Although for an insert plugin you want to call something at the beginning I think. Or halfway through sometimes. So it's complicated :)

@mitar
Copy link
Contributor Author

mitar commented Dec 22, 2014

Oh, by "But don't most plugins call insert/remove at the end?" I didn't mean that they insert at the end of the logic, but at the end of the day, they are all mostly just inserting the DOM, but doing some logic before and after it. Can then we see all this (before + insert + after) as insert itself and use it another plugin to do (something more before + (before + insert + after) + something more after).

So such extensions are quite useful to do through OOP. We define insert, beforeInsert, afterInsert, which then plugin writes have to extend and wrap into their own logic.

Just brainstorming here.

@tmeasday
Copy link
Member

Hmm, yeah that would make sense. Perhaps a plugin can define beforeInsertElement and/or afterInsertElement instead of needing to define insertElement and we synthetically put together the insertElement hook from the relevant pieces.

I think calling the helper twice is kind of ugly though. Perhaps it should just be:

{{#momentum plugin='slide-height keep-visible'}}

@mitar
Copy link
Contributor Author

mitar commented Dec 22, 2014

I think calling the helper twice is kind of ugly though. Perhaps it should just be:

That is syntactic sugar. But we should also support plugin work when nested. Because if I do:

{{#moment plugin='slide-height'}}
  {{> thirdPartyTemplate}}
{{/momentum}}

<template name="thirdPartyTemplate">
  {{#momentum plugin='keep-visible'}}
    ...
  {{/momentum}}
</template>

Thins should still work, no? So imagine that this rally becomes wide-spread. We should find a way that it is nicely composable.

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

2 participants