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

Refactor context usage #245

Merged
merged 14 commits into from Apr 22, 2019
Merged

Refactor context usage #245

merged 14 commits into from Apr 22, 2019

Conversation

micburks
Copy link
Contributor

Provide way to opt-out of legacy context for existing plugin HOCs. This will provide a path forward for existing plugins that use ProviderPlugin/HOC to consume services.

Changes

  • Refactor withServices to use ServiceContext rather than creating a new Context
  • Remove React.createContext ponyfill from withServices - only use new context
  • Add hoc.create argument to opt out of legacy context, using ServiceContext instead

Tests

  • Update test descriptions
  • Tests for withServices
  • Tests for HOC

Result
By passing the token into hoc.create, an HOC can opt out of using legacy context. You can now replace

app.register(MyToken, ProviderPlugin.create('name', MyPlugin));

with

app.register(MyToken, MyPlugin);

and your component tree will thank you.

@codecov
Copy link

codecov bot commented Apr 17, 2019

Codecov Report

Merging #245 into master will increase coverage by 1.8%.
The diff coverage is 92.5%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #245     +/-   ##
=========================================
+ Coverage      77%   78.81%   +1.8%     
=========================================
  Files          14       13      -1     
  Lines         287      269     -18     
  Branches       58       57      -1     
=========================================
- Hits          221      212      -9     
+ Misses         49       40      -9     
  Partials       17       17
Impacted Files Coverage Δ
src/index.js 71.42% <ø> (-0.99%) ⬇️
src/hoc.js 92.3% <91.3%> (-1.45%) ⬇️
src/context.js 97.5% <94.11%> (-2.5%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28a1dfe...3ca086b. Read the comment docs.

@fusionjs-bot fusionjs-bot bot added the docs label Apr 18, 2019
@@ -25,17 +25,17 @@ as bundle splitting and `fusion-react` provides tools to do it easily.
- [Usage](#usage)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The diff on the README is a mess. Summary:

  • Add [DEPRECATED] to ProviderPlugin, Provider, ProvidedHOC
  • Moved new methods to the top
  • Moved deprecated methods to the bottom
  • middleware link was dead, removed
  • Added API reference for withServices, mysteriously missing
  • Document new token parameter for ProvidedHOC.create
  • Replace PluginProvider/HOC example with useService example

@micburks
Copy link
Contributor Author

!merge

@fusionjs-bot fusionjs-bot bot merged commit 8926d39 into master Apr 22, 2019
@fusionjs-bot
Copy link

fusionjs-bot bot commented Apr 22, 2019

Triggered Fusion.js build verification: https://buildkite.com/uberopensource/fusion-release-verification/builds/2005

@fusionjs-bot fusionjs-bot bot deleted the update-context branch April 22, 2019 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants