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

Require on use #129

Merged
merged 5 commits into from
Mar 10, 2014
Merged

Require on use #129

merged 5 commits into from
Mar 10, 2014

Conversation

ryanxcharles
Copy link
Contributor

In node, in order to keep the memory overhead of bitcore low, we only want to require modules that are actually used. So to do this we replace the getters of all the bitcore.X classes with a function that only requires the class when it is accessed. That way the classes are not loaded if they are not used, and the memory overhead is kept low.

A similar feature is planned for the browser where we will compile only the modules that are directed to the browser bundle.

Ryan X. Charles added 4 commits March 10, 2014 16:47
Normally when one loads the bitcore object, all classes are loaded into memory,
even if they are not used. This comment updates this so that the classes are
only required when they are actually used, preserving memory and making bitcore
as small and light for each project. This code is only relevant for node, since
the browser will have the ability to compile only the selected components.
Also, the Key class does not yet work with this, but everything else does.
Now, like all other modules loaded in the bitcore object, Key is only required
when it is actually used. All tests pass in node and the browser.
@matiu
Copy link
Contributor

matiu commented Mar 10, 2014

ACK:

Tests OK in node,
Tests OK in browser after regenerating the bundle.

The example:
node/bitcore/examples/example.html
is not working at the browser.

The examples at examples/ for node are OK.

@ryanxcharles
Copy link
Contributor Author

Fixed the address example.

ryanxcharles pushed a commit that referenced this pull request Mar 10, 2014
@ryanxcharles ryanxcharles merged commit 73ceb2e into bitpay:master Mar 10, 2014
@maraoz
Copy link
Contributor

maraoz commented Mar 10, 2014

Excellent changes. We should add tests that run the examples so that this
doesn't happen.
I'll add the issue

On Mon, Mar 10, 2014 at 6:52 PM, Ryan X. Charles
notifications@github.comwrote:

Merged #129 #129.

Reply to this email directly or view it on GitHubhttps://github.com//pull/129
.

@matiu matiu mentioned this pull request Mar 16, 2014
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.

None yet

3 participants