{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-next/issues/671","repository_url":"https://api.github.com/repos/strongloop/loopback-next","labels_url":"https://api.github.com/repos/strongloop/loopback-next/issues/671/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-next/issues/671/comments","events_url":"https://api.github.com/repos/strongloop/loopback-next/issues/671/events","html_url":"https://github.com/strongloop/loopback-next/pull/671","id":267325867,"number":671,"title":"feat(context): Add binding options and @inject.option","user":{"login":"raymondfeng","id":540892,"avatar_url":"https://avatars0.githubusercontent.com/u/540892?v=4","gravatar_id":"","url":"https://api.github.com/users/raymondfeng","html_url":"https://github.com/raymondfeng","followers_url":"https://api.github.com/users/raymondfeng/followers","following_url":"https://api.github.com/users/raymondfeng/following{/other_user}","gists_url":"https://api.github.com/users/raymondfeng/gists{/gist_id}","starred_url":"https://api.github.com/users/raymondfeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raymondfeng/subscriptions","organizations_url":"https://api.github.com/users/raymondfeng/orgs","repos_url":"https://api.github.com/users/raymondfeng/repos","events_url":"https://api.github.com/users/raymondfeng/events{/privacy}","received_events_url":"https://api.github.com/users/raymondfeng/received_events","type":"User","site_admin":false},"labels":[{"id":668689107,"url":"https://api.github.com/repos/strongloop/loopback-next/labels/Core-GA","name":"Core-GA","color":"5319e7","default":false},{"id":570635292,"url":"https://api.github.com/repos/strongloop/loopback-next/labels/review","name":"review","color":"eeeeee","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-10-20T22:58:53Z","updated_at":"2017-10-24T16:17:40Z","closed_at":null,"author_association":"OWNER","pull_request":{"url":"https://api.github.com/repos/strongloop/loopback-next/pulls/671","html_url":"https://github.com/strongloop/loopback-next/pull/671","diff_url":"https://github.com/strongloop/loopback-next/pull/671.diff","patch_url":"https://github.com/strongloop/loopback-next/pull/671.patch"},"body":"1. Add options property and withOptions method for a binding\r\n2. Pass binding to dependency resolution\r\n3. Add @injection.option to receive injection of options\r\n4. Fix routing table to use dependency injection\r\n\r\n### Description\r\n\r\n\r\n#### Related issues\r\n\r\n<!--\r\nPlease use the following link syntaxes:\r\n\r\n- connect to #49 (to reference issues in the current repository)\r\n- connect to strongloop/loopback#49 (to reference issues in another repository)\r\n-->\r\n\r\n- connect to https://github.com/strongloop/loopback-next/pull/631\r\n- connect to https://github.com/strongloop/loopback-next/issues/543\r\n\r\n### Checklist\r\n\r\n<!--\r\n- Please mark your choice with an \"x\" (i.e. [x], see\r\nhttps://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments)\r\n- PR's without test coverage will be closed.\r\n-->\r\n\r\n- [x] New tests added or existing tests modified to cover all changes\r\n- [x] Code conforms with the [style\r\n  guide](http://loopback.io/doc/en/contrib/style-guide.html)\r\n"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-next/issues/comments/339046663","html_url":"https://github.com/strongloop/loopback-next/pull/671#issuecomment-339046663","issue_url":"https://api.github.com/repos/strongloop/loopback-next/issues/671","id":339046663,"user":{"login":"raymondfeng","id":540892,"avatar_url":"https://avatars0.githubusercontent.com/u/540892?v=4","gravatar_id":"","url":"https://api.github.com/users/raymondfeng","html_url":"https://github.com/raymondfeng","followers_url":"https://api.github.com/users/raymondfeng/followers","following_url":"https://api.github.com/users/raymondfeng/following{/other_user}","gists_url":"https://api.github.com/users/raymondfeng/gists{/gist_id}","starred_url":"https://api.github.com/users/raymondfeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raymondfeng/subscriptions","organizations_url":"https://api.github.com/users/raymondfeng/orgs","repos_url":"https://api.github.com/users/raymondfeng/repos","events_url":"https://api.github.com/users/raymondfeng/events{/privacy}","received_events_url":"https://api.github.com/users/raymondfeng/received_events","type":"User","site_admin":false},"created_at":"2017-10-24T16:17:39Z","updated_at":"2017-10-24T16:17:39Z","author_association":"OWNER","body":"> We can make the options a binding like interface so that the values can be resolved the same way as bindings.\r\n\r\nI take it back. Maybe it's not necessary. If we consider how `options` is added to a binding, for example:\r\n```ts\r\nctx.bind('authentication.strategies.ldap').toClass(LDAPStrategy).withOptions(...);\r\n```\r\nSince we have access to `ctx`, we can configure an option as a promise that can be resolved from a binding of the ctx or its child. For example:\r\n```\r\nclass MyOptionProvider implements Provider<MyOption> {\r\n  constructor(@inject(...) ...) {}\r\n  value() {\r\n    // ...\r\n  }\r\n}\r\nctx.bind('options.MyOptionProvider').toProvider(MyOptionProvider);\r\n\r\nconst options = {\r\n  myOption: ctx.get('options.MyOptionProvider'),\r\n}\r\n```"}}
{"actor":{"display_login":"raymondfeng"}}