-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Feature: Extend setAddon API #1463
Conversation
Codecov Report
@@ Coverage Diff @@
## release/3.3 #1463 +/- ##
==============================================
- Coverage 22.32% 15.93% -6.4%
==============================================
Files 324 237 -87
Lines 6319 5051 -1268
Branches 803 629 -174
==============================================
- Hits 1411 805 -606
+ Misses 4297 3715 -582
+ Partials 611 531 -80
Continue to review full report at Codecov.
|
Super interesting idea. However, personally I'd vote against expanding the API at all until we get the existing API working better. |
This approach can help us to get rid of global decorators: Instead of adding them globally |
Closing this because there hasn't been any activity here for a while. Feel free to reopen when this is ready for discussion again. |
The current API:
It adds addons to
storiesOf()
object and they accessible as methods:Why we need new API
Sometimes we want to implement some features or some behavior to
storiesOf()
to have it by default. This would open up a plenty new directions in the addons creation!What I did
Just allow passing into
setAddon
functions matching/^_init/
and make them executed right afterstoriesOf()
is created.This is a backward compatible change, addons with normal names still work the same.
New API
when you create:
_initSmth()
will not be accessible as a method ofstoriesOf()
but it will be already executedHow to test
run cra-kitchen-sink
check out the Toc first story of each storyKind (it just an example of how it works)
check that other addons work as usual