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

Modularize Response's methods #19

Open
ryanve opened this issue Jan 11, 2013 · 2 comments
Open

Modularize Response's methods #19

ryanve opened this issue Jan 11, 2013 · 2 comments

Comments

@ryanve
Copy link
Owner

ryanve commented Jan 11, 2013

Response's methods fit into two categories:

  • response-specific methods only applicable to response.js (.create(), .addTest(), etc.)
  • general-purpose methods that are generally applicable (.dataset(), .viewportW(), etc.) Some of these are better aligned with the "responsive design toolkit" goal than others

The current homepage is focused on the breakpoint-swapping feature. After the 0.3 changes (when several methods were made public) I started working on a new version of the docs here. Yet I hesitated to put that on the homepage in fear of documenting any methods that might soon change.

Putting general-purpose methods public can be useful. But once they're documented then they are expected to be supported�—regardless of whether or not it is internally needed. In retrospect I might not have made the object utilities or the dataset methods public because they are not internally needed.

In an effort to better modularize the code, I want to better separate the general-purpose methods from the response-specific ones. This will greatly improve maintainability. Support multiple libraries jQuery/Zepto/ender complicates the issue. I'm trying to figure out the most practical way to go about it.

@ryanve
Copy link
Owner Author

ryanve commented Oct 6, 2013

NPM modules that use UMD (like verge) could be added as devDependencies and bundled via grunt into this pattern:

!function(root, name, make, bundle) {
    make = make.call(root, bundle);
    if (typeof module != 'undefined' && module['exports']) module['exports'] = make;
    else root[name] = make;
}(this, 'Response', function(bundle) {
    // Make export here with private access to bundle.
    return {}; // Return export with properties/methods.
}, function(module, define) {
    // Dependencies (inserted via grunt) run in controlled scope.
}.call({}));

@ryanve
Copy link
Owner Author

ryanve commented Mar 29, 2014

An alternative to bundling is require the needed modules as dependencies but not bundle them. Devs would need to do bundle via browserify, ender, or otherwise. How are most of you are consuming Response? My guess is that many are using jQuery and separate <script> tags, but using build tools is better. What build tools do you prefer to use?

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

No branches or pull requests

1 participant