Giter VIP home page Giter VIP logo

Comments (7)

athaeryn avatar athaeryn commented on July 20, 2024

Hey! Love that you did this. That said, I do already have a plan for how to remove the jQuery dependency.

It will be similar to Backbone.$. By default, Boba will try and use window.$. If it can't find that, you'll have to provide a shim object with functions compatible with jQuery's API, like this:

Boba.$ = {
  extend: function(target, object) { ... },
  on: function(element, event, selector, handler) { ... },
  proxy: function(func, context) { ... }
}

If you're using Underscore.js, you could use something like this:

Boba.$ = {
  extend: _.extend,
  proxy: _.bind,
  // Underscore doesn't have anything for this, we'd have to write it ourselves
  on: function(element, event, selector, handler) { ... }
}

The on function will be different, since it's called on a jQuery object. I'm thinking Boba will include something like this:

Boba.$.on = function(el) {
  Boba.$.fn.on.apply($(el), Array.prototype.splice.call(arguments, 1))
}

The point is, I don't want Boba to include ancillary functions. I'd rather have a shims/ folder, and probably have different builds using each of the shims.

I'd love to hear other people's thoughts!

from boba.js.

nicinabox avatar nicinabox commented on July 20, 2024

My first thought as a developer is, "Yeah, shims would be cool!", but my first thought as a user is, "Why can't it just work OOTB?"

The level of complexity necessary to hide a loop and a closure is crazy. And you still don't get a good listener for on.

Boba tries to make working with GA easier, right? IMO, supplanting the user's problem (tracking) with writing extra methods just to get it to work seems dubious.

from boba.js.

athaeryn avatar athaeryn commented on July 20, 2024

Oh, it would work out of the box with jQuery, and there would be other versions (in a dist/ folder or something) that would work with things like Underscore.js or just vanilla JS.

from boba.js.

athaeryn avatar athaeryn commented on July 20, 2024

Sorry, I probably didn't explain very well before. Boba at it's core would use jQuery if present, and require a shim otherwise. The shims would live in a shims/ folder, so that anyone could contribute one. I'd add a gulp task to build each shim into the dist/ folder, so you could grab, say, a jQuery-free version from there.

from boba.js.

nicinabox avatar nicinabox commented on July 20, 2024

It's up to you ultimately how you want to do it. I think it's a bit silly to shim a for loop and a closure. There's nothing wrong with these patterns or having them in the core code. The complexity created by offloading to dependency x creates far more friction for maintenance/contributors and end users.

Suddenly it becomes not an easy drop in replacement-- you need to know something about it, you need to pick the right shim and be aware of potential conflicts. For a 100-line abstraction, that kind of peripheral knowledge shouldn't be a prerequisite.

from boba.js.

bradgreens avatar bradgreens commented on July 20, 2024

An idea could be to stick mainly to ES5 methods, such as Array.prototype.forEach and suggest the ES5-shim for users needing to support IE8 or other non-compliant browsers. I think writing it lean and adding an ES5 or jQuery adapter is a good pattern. It would support those who require wide-range browser support, and those of us who do not have that concern.

from boba.js.

athaeryn avatar athaeryn commented on July 20, 2024

I think I'm just going to merge this (when you submit the PR). Eventually I'll get around to implementing things the way I'd like them, but this is good for now.

from boba.js.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.