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

Proposal: optionalMustDeps for optional entities #92

Open
tenorok opened this issue Jun 5, 2017 · 3 comments
Open

Proposal: optionalMustDeps for optional entities #92

tenorok opened this issue Jun 5, 2017 · 3 comments

Comments

@tenorok
Copy link

tenorok commented Jun 5, 2017

There are cases when we have a block which have a few optional modifiers. These modifiers can be included to bundle at the same time or separately. And in the case when they are included together the order becomes important.

I'm propose feature like include: false, but more understandable for community.

Consider the example.
Block filter is just a button in the common case.

block('filter').content()({ block: 'button' });

It have optional ability to show tooltip on mouseover. Code for this feature locate in the modifier _hoverable_yes. Template of this modifier adds to content the tooltip.

block('filter').mod('hoverable', 'yes').content()(function() {
  return [
    applyNext(),
    { block: 'tooltip' }
  ];
});

Also block have other optional ability to turn into dropdown. Code for this feature locate in the modifier _changable_yes. Template of this modifier replace content of the main template to dropdown.

block('filter').mod('changable', 'yes').content()({ block: 'dropdown' });

Now, on case when block has both these modifiers order becomes important. We can declare it in the filter_hoverable_yes.deps.js.

({
  shouldDeps: [
    { block: 'tooltip' }
  ],
  optionalMustDeps: [
    { mods: { changable: 'yes' } }
  ]
});

Guys what do you think about it?

@skad0
Copy link
Member

skad0 commented Jun 5, 2017

Hi! Thanks for your interest.

I don't understand what optionalMustDeps should mean? Another level of 'priority' for sorting dependencies? Something like, mustDeps, but less strong?

And for your example, you can e.g. keep content in element and replace content of element with block dropdown.

@qfox
Copy link
Contributor

qfox commented Jun 5, 2017

It's something like:

({
  mustDeps: [
    { mods: { changable: 'yes' }, include: false }
  ]
});

Right?

@tenorok
Copy link
Author

tenorok commented Jun 5, 2017

@zxqfox yes, it seems right.
Section optionalMustDeps mean that entities inside it must be included to build before current entity when they are participate in build. That is, if neither one block not require entities which specified in optionalMustDeps – these entities will not be included into the build.

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

3 participants