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

[RFC - WIP] Context watcher for bindings that can come and go #2111

Closed
wants to merge 1 commit into from

Conversation

raymondfeng
Copy link
Contributor

@raymondfeng raymondfeng commented Dec 3, 2018

This PR serves as a PoC to enable reactive context bindings to support the following use cases:

  1. Add ContextWatcher to use a filter function to watch the context
  2. The ContextWatcher maintains a cache of matched bindings/values. The list can be updated after initialization upon events from the context.
  3. Subscribe ContextWatcher to the context chain to receive notifications.
  4. Introduce @inject.filter with the option to receive a live of list of matching binding values. Reimplement @inject.tag to leverage it.

Checklist

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

@raymondfeng raymondfeng requested a review from bajtos as a code owner December 3, 2018 23:51
@raymondfeng raymondfeng changed the title [RFC - WIP] Binding tracker [RFC - WIP] Context watcher for bindings that can come and go Dec 3, 2018
@bajtos
Copy link
Member

bajtos commented Dec 4, 2018

@raymondfeng to make it easier for reviewers to understand these changes in wider context, please add few high-level acceptance tests to demonstrate the scenarios you are trying to address.

  • As an application developer, I want to ...
  • As an extension developer, I want to ...

You are also mentioning the use case "controllers can be added the application after it starts", can you perhaps update @loopback/rest to show how your new APIs can be leveraged to implement that feature?

- ContextWatcher - watches matching bindings of a context and maintain
  a live collection of values
- @Inject.filter - injects an array of values resolved from bindings
  that match the filter function
@raymondfeng
Copy link
Contributor Author

@bajtos Added some acceptance tests.

@raymondfeng raymondfeng closed this Dec 4, 2018
@raymondfeng raymondfeng deleted the binding-tracker branch December 4, 2018 23:20
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

Successfully merging this pull request may close these issues.

2 participants