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

Modifier managers #373

Merged
merged 5 commits into from
Oct 19, 2018
Merged

Modifier managers #373

merged 5 commits into from
Oct 19, 2018

Conversation

chadhietala
Copy link
Contributor

@chadhietala chadhietala commented Sep 10, 2018

import EmberObject from '@ember/object';
import { setModifierManager } from '@ember/modifier';

export default setModifierManager('basic', EmberObject.extend({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a better question for @mixonic over in #367 (since setComponentManager already exists and likely faces the same question), but given that this API is primarily expected to be consumed from addons, how does this work with MU/explicit packages?

Would it be something like setModifierManager('super-cool', { package: 'super-cool-modifiers' }, EmberObject.extend(...))?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think your suggestion makes sense, but would you mind chiming in over in #367?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me, if mildly annoying for authors. Given that this is a low-level API the annoyance is probably permissible.

I think the most direct way forward is to update this RFC to include both MU and non-MU examples for how to use the setModifierManager API. This will help focus the number of cases and solutions, which are really not that many.

just inline them in the `app` tree directly for the examples in this RFC.)

This allows the modifier manager to participate in the DI system – receiving
injections, using services, etc. Alternatively, component managers can also

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

component managers -> modifier managers


Here is a hypothical scenario for such a change:

1. Ember 3.2 implemented and shipped the modifier manager API as described in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 3.6 instead of 3.2? Seems to fit better with the rest of the hypotheticals below ...

@ryanto
Copy link

ryanto commented Sep 14, 2018

Might be a dumb q, but how does this relate to the Modifiers RFC?

Is the idea here that this happens first? Experiment with a modifier APIs through various managers + capabilities?

@sandstrom
Copy link
Contributor

sandstrom commented Sep 14, 2018

I vote for the alternative suggested at the end of this RFC:

Instead of exposing low-level primitives we should ship the high level API as described in RFC#353

I understand the thinking behind exposing primitives — and I like that. But I'd say that the original modifiers RFC #353 already do expose primitives. This RFC is taking it a bit too far, by exposing ’primitives behind the primitives‘.

Also, there are always resource constraints and for everything you decide to do, there is one thing that you're not doing. The idea presented here isn't inherently bad, but I'd like to question whether it's on the top 10 list of things that the Ember community want to prioritize. In my opinion #353 already give us 90% of the tools we need, and we should simply ignore the remaining 10% (this RFC) and focus on other things in Ember land.

All that said, I want to point out that I have a lot of respect for your contributions to Ember @chadhietala 🏅, and I really like and support the original RFC (#353).


As an aside I'd like to mention that the capabilities concept is clever and if this RFC ends up being shelved the capabilities concept may be useful for other things related to addons.

@mixonic
Copy link
Sponsor Member

mixonic commented Sep 18, 2018

@ryanto Yes, this RFC is suggested as the first implementation path for modifiers in Ember. It would allow us to implement whatever high-level helpers we want for the framework as addons, and skip over the challenge of an app-developer-friendly design for authoring modifiers. As is evinced in #353 there are some tricky things to design for an app-developer-friendly design, such as the interaction with FastBoot and how much of a similar-to-current-components-vs-future-glimmer-components tradeoff to make.

@chadhietala
Copy link
Contributor Author

I have updated the RFC to show how we will associate the manager and the base class. The TL;DR is to pass the import binding.

// my-app/app/modifier/foo.js

import EmberObject from '@ember/object';
import Basic from './basic-manager';
import { setModifierManager } from '@ember/modifier';

export default setModifierManager(Basic, EmberObject.extend({
  // ...
}));

There should be a similar RFC for setComponentManager.

@chadhietala
Copy link
Contributor Author

chadhietala commented Oct 5, 2018

After the core team call today we decided that a better API would be to pass a function that receives an Owner and returns an instance of the custom manager. This design allows for some indirection (if needed) and general speaking allows us to code against the interface instead of the concretion.

import EmberObject from '@ember/object';
import { createManager } from './basic-manager';
import { setModifierManager } from '@ember/modifier';

export default setModifierManager(createManager, EmberObject.extend({
  // ...
}));
// my-app/app/modifier/basic-manager.js

// ...

export function createManager(owner) {
  return new BasicManager(owner);
}

@rwjblue
Copy link
Member

rwjblue commented Oct 6, 2018

After reviewing this at the core team meeting yesterday, we are in favor of this moving into the final comment period.

@rwjblue
Copy link
Member

rwjblue commented Oct 19, 2018

Lets do this!

@rwjblue rwjblue merged commit 82ae4ac into master Oct 19, 2018
@rwjblue rwjblue deleted the modifier-managers branch October 19, 2018 18:21
This was referenced Oct 22, 2018
alexdiliberto pushed a commit to alexdiliberto/ember-transformicons that referenced this pull request Mar 6, 2019
Bumps [ember-source](https://github.com/emberjs/ember.js) from 3.7.3 to 3.8.0.
<details>
<summary>Release notes</summary>

*Sourced from [ember-source's releases](https://github.com/emberjs/ember.js/releases).*

> ## v3.8.0
> ### CHANGELOG
> 
> - [#17143](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17143) / [#17375](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17375) [FEATURE] Implement Element Modifier Manager RFC (see [emberjs/rfcs#373](https://github.com/emberjs/rfcs/blob/master/text/0373-Element-Modifier-Managers.md)).
> - [#17054](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17054) / [#17376](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17376) [FEATURE] Implement `array` helper RFC (see [emberjs/rfcs#318](https://github.com/emberjs/rfcs/blob/master/text/0318-array-helper.md))
> - [#16735](https://github-redirect.dependabot.com/emberjs/ember.js/pull/16735) [BUGFIX] Observed properties not being marked as enum
> - [#17498](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17498) [BUGFIX] Don't remove dep keys in `didUnwatch`
> - [#17467](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17467) [BUGFIX] Fix substate interactions with aborts
> - [#17413](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17413) [BUGFIX] Fix missing import in instance-initializer blueprint for ember-mocha
> - [#17319](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17319) [CLEANUP] Remove deprecated 'POSITIONAL_PARAM_CONFLICT'
> - [#17394](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17394) [CLEANUP] Remove deprecated code in mixins/array
> - [#17244](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17244) / [#17499](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17499) Upgrade to Glimmer VM 0.37.1
> Fixes a few issues:
>   * Usage of positional arguments with custom components.
>   * Forwarding attributes via `...attributes` to a dynamic component.
>   * Prevent errors when rendering many template blocks (`Error: Operand over 16-bits. Got 65536`).
> - [#17166](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17166) Improve performance of get() / set()
> - [#16710](https://github-redirect.dependabot.com/emberjs/ember.js/pull/16710) Deprecation of private `NAME_KEY`
> - [#17216](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17216) Use native Error instead of custom Error subclass.
> - [#17340](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17340) Remove unused `hooks` variable from qunit-rfc-232 util-test blueprint
> - [#17357](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17357) Allow notifyPropertyChange to be imported from @ember/object
> 
> 
> ## v3.8.0-beta.5
> ### CHANGELOG
> 
> - [#17563](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17563) [BUGFIX] Transition.send/trigger call signature
> 
> ## v3.8.0-beta.4
> ### CHANGELOG
> 
> - [#17552](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17552) [BUGFIX] Support numbers in component names for Angle Brackets
> 
> ## v3.8.0-beta.3
> ### CHANGELOG
> 
> - [#17498](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17498) [BUGFIX] Don't remove dep keys in `didUnwatch`
> - [#17499](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17499) [BUGFIX] Update to glimmer-vm 0.37.1.
> 
> ## v3.8.0-beta.2
> ### CHANGELOG
> 
> - [#17467](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17467) [BUGFIX] Fix substate interactions with aborts
> 
> ## v3.8.0-beta.1
> ### CHANGELOG
> 
> - [#17143](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17143) / [#17375](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17375) [FEATURE] Implement Element Modifier Manager RFC (see [emberjs/rfcs#373](https://github.com/emberjs/rfcs/blob/master/text/0373-Element-Modifier-Managers.md)).
> - [#17054](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17054) / [#17376](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17376) [FEATURE] Implement `array` helper RFC (see [emberjs/rfcs#318](https://github.com/emberjs/rfcs/blob/master/text/0318-array-helper.md))
> - [#16735](https://github-redirect.dependabot.com/emberjs/ember.js/pull/16735) [BUGFIX] Observed properties not being marked as enum
></tr></table> ... (truncated)
</details>
<details>
<summary>Changelog</summary>

*Sourced from [ember-source's changelog](https://github.com/emberjs/ember.js/blob/master/CHANGELOG.md).*

> ### v3.8.0 (February 18, 2019)
> 
> - [#17143](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17143) / [#17375](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17375) [FEATURE] Implement Element Modifier Manager RFC (see [emberjs/rfcs#373](https://github.com/emberjs/rfcs/blob/master/text/0373-Element-Modifier-Managers.md)).
> - [#17054](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17054) / [#17376](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17376) [FEATURE] Implement `array` helper RFC (see [emberjs/rfcs#318](https://github.com/emberjs/rfcs/blob/master/text/0318-array-helper.md))
> - [#16735](https://github-redirect.dependabot.com/emberjs/ember.js/pull/16735) [BUGFIX] Observed properties not being marked as enum
> - [#17498](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17498) [BUGFIX] Don't remove dep keys in `didUnwatch`
> - [#17467](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17467) [BUGFIX] Fix substate interactions with aborts
> - [#17413](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17413) [BUGFIX] Fix missing import in instance-initializer blueprint for ember-mocha
> - [#17319](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17319) [CLEANUP] Remove deprecated 'POSITIONAL_PARAM_CONFLICT'
> - [#17394](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17394) [CLEANUP] Remove deprecated code in mixins/array
> - [#17244](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17244) / [#17499](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17499) Upgrade to Glimmer VM 0.37.1
> Fixes a few issues:
>   * Usage of positional arguments with custom components.
>   * Forwarding attributes via `...attributes` to a dynamic component.
>   * Prevent errors when rendering many template blocks (`Error: Operand over 16-bits. Got 65536`).
> - [#17166](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17166) Improve performance of get() / set()
> - [#16710](https://github-redirect.dependabot.com/emberjs/ember.js/pull/16710) Deprecation of private `NAME_KEY`
> - [#17216](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17216) Use native Error instead of custom Error subclass.
> - [#17340](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17340) Remove unused `hooks` variable from qunit-rfc-232 util-test blueprint
> - [#17357](https://github-redirect.dependabot.com/emberjs/ember.js/pull/17357) Allow notifyPropertyChange to be imported from @ember/object
</details>
<details>
<summary>Commits</summary>

- [`3013779`](emberjs/ember.js@3013779) Release v3.8.0
- [`43e8cb6`](emberjs/ember.js@43e8cb6) Add v3.8.0 to CHANGELOG
- [`899be80`](emberjs/ember.js@899be80) Release v3.8.0-beta.5
- [`39bb0d4`](emberjs/ember.js@39bb0d4) Add v3.8.0-beta.5 to CHANGELOG
- [`494d83d`](emberjs/ember.js@494d83d) [DOC beta] Add deprecation tag for Ember.merge
- [`472673d`](emberjs/ember.js@472673d) [DOC lts] Addressed PR comments by rwjblue
- [`8a42b3b`](emberjs/ember.js@8a42b3b) [DOC lts] Addressed PR comments
- [`71c2fe5`](emberjs/ember.js@71c2fe5) [DOC] Angle Bracket invocation
- [`4a67315`](emberjs/ember.js@4a67315) Add v3.7.3 to CHANGELOG
- [`3db1a75`](emberjs/ember.js@3db1a75) Bump router_js from 6.2.2 to 6.2.3
- Additional commits viewable in [compare view](emberjs/ember.js@v3.7.3...v3.8.0)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=ember-source&package-manager=npm_and_yarn&previous-version=3.7.3&new-version=3.8.0)](https://dependabot.com/compatibility-score.html?dependency-name=ember-source&package-manager=npm_and_yarn&previous-version=3.7.3&new-version=3.8.0)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

**Note:** This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

You can always request more updates by clicking `Bump now` in your [Dependabot dashboard](https://app.dependabot.com).

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants