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

docs: update dependency injection examples #3024

Merged
merged 1 commit into from
Jun 13, 2019

Conversation

emonddr
Copy link
Contributor

@emonddr emonddr commented May 31, 2019

Update dependency injection examples that mention authentication

Related to : #2940

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • 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

👉 Check out how to submit a PR 👈

@emonddr emonddr self-assigned this May 31, 2019
Copy link
Contributor

@jannyHou jannyHou left a comment

Choose a reason for hiding this comment

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

@emonddr I added one more thing to update, otherwise LGTM :shipit: good update!

The test failures should be fixed after a rebase.

}
server
.bind(JWTAuthenticationStrategyBindings.TOKEN_EXPIRES_IN)
.to('600');
```

However, when you want to create a binding that will instantiate a class and
Copy link
Contributor

Choose a reason for hiding this comment

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

@emonddr One more thing to update here:

However, when you want to create a binding that will instantiate a configured class(as a provider) and automatically inject required dependencies, then you need to use .toProvider() method:

server
  .bind(AuthenticationBindings.AUTH_ACTION)
  .toProvider(AuthenticateActionProvider);

const provider = await server.get(AuthenticationBindings.AUTH_ACTION);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jannyHou , the existing document used the AuthenticateActionProvider in a .toClass() and in the .toProvider() example.

I've changed the .toClass() example code to use a different class instead; so 1) it is less confusing as to why different binding methods were used on the same class, and 2) so I don't have to change the explanatory paragraph:

image

@raymondfeng
Copy link
Contributor

In the longer term, I wonder if we should use simpler examples at https://github.com/strongloop/loopback-next/tree/master/examples/context for the DI docs.

@emonddr emonddr force-pushed the dremond_docs_update_dep_injection branch from 4a019c5 to 1903e4b Compare June 4, 2019 12:55
@emonddr
Copy link
Contributor Author

emonddr commented Jun 4, 2019

@raymondfeng

In the longer term, I wonder if we should use simpler examples at https://github.com/strongloop/loopback-next/tree/master/examples/context for the DI docs.

Hi Raymond, with the examples I have in place at the moment of my 2nd commit, are you satisfied with the 3 different examples (for the purposes of the authentication documentation changes), and want to create a separate task for modifying these dependency injection examples to be done at a later time? Or are you saying that my PR should use non-authentication examples right now?
Please advise.

Copy link
Contributor

@jannyHou jannyHou left a comment

Choose a reason for hiding this comment

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

:shipit: LGTM please rebase the branch before merging.

@emonddr emonddr force-pushed the dremond_docs_update_dep_injection branch from 1903e4b to 36d480c Compare June 6, 2019 17:06
@raymondfeng
Copy link
Contributor

Hi Raymond, with the examples I have in place at the moment of my 2nd commit, are you satisfied with the 3 different examples (for the purposes of the authentication documentation changes), and want to create a separate task for modifying these dependency injection examples to be done at a later time? Or are you saying that my PR should use non-authentication examples right now?
Please advise.

I'm fine to use authentication examples for now. It would be ideal to use simpler standalone examples in the future PRs.

@emonddr
Copy link
Contributor Author

emonddr commented Jun 6, 2019

@raymondfeng

I'm fine to use authentication examples for now. It would be ideal to use simpler standalone examples in the future PRs.

Me too. Ok thanks. Can you approve it then? And then I will rebase, etc. Thanks :)

@emonddr emonddr force-pushed the dremond_docs_update_dep_injection branch 4 times, most recently from ddace71 to 3a4b1f7 Compare June 12, 2019 12:06
@emonddr emonddr removed the request for review from bajtos June 12, 2019 12:06
@emonddr emonddr force-pushed the dremond_docs_update_dep_injection branch 2 times, most recently from 6e0ee45 to 6620e39 Compare June 12, 2019 20:53
Update dependency injection examples that mention authentication
@emonddr emonddr force-pushed the dremond_docs_update_dep_injection branch from 6620e39 to cb95e91 Compare June 13, 2019 02:24
@emonddr emonddr merged commit 8355bfb into master Jun 13, 2019
@delete-merged-branch delete-merged-branch bot deleted the dremond_docs_update_dep_injection branch June 13, 2019 02:44
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.

3 participants