Git Product home page Git Product logo

Comments (17)

matthew-andrews avatar matthew-andrews commented on July 26, 2024

The function to set the dom element of an already instantiated delegate object could be

function watch(root) {
  // TODO: Add the code that is currently in the
  // constructor, then in the constructor call this
  // function if the argument is provided.
}

from ftdomdelegate.

mattcg avatar mattcg commented on July 26, 2024

How about attach and detach? The method watch seems to imply that you can keep adding root elements on which to listen for events, but we don't support that.

from ftdomdelegate.

matthew-andrews avatar matthew-andrews commented on July 26, 2024

attach also seems to imply that you can keep adding root elements too...

from ftdomdelegate.

mattcg avatar mattcg commented on July 26, 2024

You're right. How about pause and play, with play accepting a new root as the argument?

from ftdomdelegate.

matthew-andrews avatar matthew-andrews commented on July 26, 2024

If we could use bind and unbind (rebind?) that would be perfect. (jQuery sets up functions with these names - maybe we can too? May get confusing with the native js function bind though)

Pause and play imply you could temporarily stop the delegate (pause();) and then restore it to use its original root element (play();) which I don't think is needed...

(iPhone GitHub app so apologies for no grammar)

from ftdomdelegate.

mattcg avatar mattcg commented on July 26, 2024

Pause and play imply you could temporarily stop the delegate (pause();) and then restore it to use its original root element (play();)

I actually like this. bind and unbind are a bit vague - I think even people who use jQuery have to check the documentation every time. In our case it'd be worse because we'd also have on and off.

So we'd have pause and play, which leave the list of registered callbacks unaffected, and destroy which resets everything.

from ftdomdelegate.

mattcg avatar mattcg commented on July 26, 2024

Changed my mind. unbind would allow us to discard the reference to the root node, and that's what we want :)

from ftdomdelegate.

matthew-andrews avatar matthew-andrews commented on July 26, 2024

We could still implement destroy which would be:-

delegate.prototype.destroy = function () {
  this.unbind();
  this.off();
}

from ftdomdelegate.

wilsonpage avatar wilsonpage commented on July 26, 2024

I agree with earlier comments. The 'bind'/'unbind' syntax is confusing. If I'm familiar with jQuery I would assume that this was the API (or an alias to the on/off methods) for attaching and removing events. I suggest delegate.root(el); and something like delegate.clearRoot(); or delegate.root('clear');

Feel free to ignore me :)

from ftdomdelegate.

matthew-andrews avatar matthew-andrews commented on July 26, 2024

I accept it is a little confusing but I think we can do better than root and clearRoot.

What do we have so far...
watch & unwatch
attach & detach
play & pause
bind & unbind
root & clearRoot

Some more to throw into the mix:-
tie & untie
link & unlink
enslave & liberate / free
connect & disconnect
hold & release
represent & betray
apple & cranberry
marry & divorce (https://twitter.com/TheTeethgrinder/status/293472511788711936)

from ftdomdelegate.

wilsonpage avatar wilsonpage commented on July 26, 2024

lol! Loving this. Such evocative words for assigning an element to an instance!

What about:

delegate.el(element) // assign
delegate.el() //unassign

from ftdomdelegate.

matthew-andrews avatar matthew-andrews commented on July 26, 2024

No hablo español.

setRoot(element) & setRoot() ?

from ftdomdelegate.

wilsonpage avatar wilsonpage commented on July 26, 2024

Ok. Why not:

delegate.root(element);
delegate.root();

?

from ftdomdelegate.

matthew-andrews avatar matthew-andrews commented on July 26, 2024

unroot?

from ftdomdelegate.

matthew-andrews avatar matthew-andrews commented on July 26, 2024

root and uproot !!!

from ftdomdelegate.

wilsonpage avatar wilsonpage commented on July 26, 2024

Too clever! Chill out ;)

I guess unroot works. I'm just alway in favour of keeping the interface as small as possible (if possible). Especially with a lib as small as this.

from ftdomdelegate.

matthew-andrews avatar matthew-andrews commented on July 26, 2024

Sold. Let's go with root(element) and root().

from ftdomdelegate.

Related Issues (20)

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.