Comments (19)
Looks like the node-util
and the built-in util
are not exactly the same.
Here is the util
lib from core:
https://github.com/joyent/node/blob/master/lib/util.js#L632-L642
Even in 0.10
:
https://github.com/joyent/node/blob/09b482886bdd3d863c3d4e7d71264eac0daaf9e1/lib/util.js#L554-L564
from dispatchr.
Good point. They aren't exactly the same. It seems node-util
hasn't been updated in a year.
After browserifying, I see the entire util
module included in my bundle. Is this necessary?
from dispatchr.
That doesn't sound desirable. IIRC Webpack has some optimizations we're taking advantage of to prevent this.
Here is our webpack config:
https://github.com/yahoo/fluxible.io/blob/master/Gruntfile.js#L123-L135
from dispatchr.
The 'util' lib it is not really necessary we can do inheritance without it.
from dispatchr.
Agreed.
from dispatchr.
I think the best course of action might be to use the inherits
module that @ezequiel mentions. It's 100% compatible with node.
from dispatchr.
But Object.create
is 100% compatible with node and the browser also it won't add any extra code to webpack
from dispatchr.
take a look at the source code for https://github.com/joyent/node/blob/master/lib/util.js#L632-L642 it is just a wrapper for MyClass.prototype = Object.create(ParentClass.prototype);
from dispatchr.
inherits
also sets MyClass._super
and ensures that MyClass.prototype.constructor
is set correctly. It's possible that downstream users are relying on these.
from dispatchr.
I think the best solution would be to use ES6 classes this way we get real classes, but if we cannot do that yet it would be good to minimize dependencies.
The standard javascript way of Pseudo-classical inheritance is the one I sent on the PR and you can also see that example here => https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FObject%2Fcreate.
I never saw a case where the super_
was a good idea, would you ever use something like this.constructor.super_.someMethod.call(this, args)
?
from dispatchr.
The node/utils
file is 20kb but I am not sure how webpack optimizes it. Usually it is a good idea to make JS libs as small and with as few dependencies as possible.
from dispatchr.
👍 I was having that same issue of webpack it would be cool to remove that dependency.
from dispatchr.
We are going to switch over to the inherits
npm module for now until we start using ES6 classes.
from dispatchr.
ES6 classes?! That sounds awesome! 👍
from dispatchr.
are we going to use ES6 modules too? http://www.2ality.com/2014/09/es6-modules-final.html
from dispatchr.
Yeah. We need to get the builds figured out first, but we will use babel to generate ES5 exports.
from dispatchr.
This has been released in v0.3.0.
from dispatchr.
this doesn't appear to be released, possibly someone merged back use of 'util' module. It is unclear from commit history
from dispatchr.
You're totally right. Will look into this.
from dispatchr.
Related Issues (20)
- Investigate Synchronous Dispatching
- Investigate replay-based rehydration HOT 8
- Handler definitions as functions to promote a sort of Revealing Module Pattern
- Add helper functions to Readme
- Bowerify the dispatchr HOT 3
- Encourage passing constructors to getStore and waitFor instead of strings HOT 1
- Ability to have handler for all actions HOT 4
- React errors caused by BaseStore emit do not reach the console HOT 3
- can emitChange from store support passing a paylod that holds an id HOT 6
- Pull `/utils/BaseStore.js` into it's own module HOT 2
- Does createStore support mixing in event handlers? HOT 3
- Introduce store method `shouldDehydrate` to disable dehydration for a store HOT 2
- Errors during action handlers HOT 5
- Why the Dispatcher don't return the class directly? HOT 11
- Throw an error if actionName passed to Dispatcher#dispatch is undefined HOT 4
- docblock incorrectly mentions queueing
- Tie together multiple actions of one async operation HOT 2
- createStore does not expose store in dehydrated context.dispatcher.stores HOT 3
- Unable to affect state asynchronously from store, apply component `this` to handler function? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dispatchr.