ractivejs / ractivejs.github.io

https://ractive.js.org
8 stars 33 forks source link

Documentation for shouldBind option on ractive.get() #92

Open lazylester opened 7 years ago

lazylester commented 7 years ago

I have discovered an undocumented "shouldBind" option on the ractive.get() method. Turns out I needed this option to solve a problem with unexpected ractive behaviour (ref: this stack overflow question.

Assuming that this option is intended to be available in the public api (is it? I hope so b/c it solved my problem!), would it be possible, please, to provide documentation?

I would offer a PR except I don't really understand the intent of the shouldBind option, just its effect.

evs-chris commented 7 years ago

It's not intended to be part of the public API, unfortunately. It's intended for internal use so that cross-instance mappings can bind their root functions to the correct instance. Basically, if a function appears at the root of ractive data, it is automatically bound. If you want to avoid binding, put functions in a nested keypath.

We could add an escape hatch for that, but up to this point, it's been unnecessary.

lazylester commented 7 years ago

@evs-chris can I prevail upon you, please, to look at my stack overflow question (referenced above). I ran into some unexpected behaviour which was nicely solved with the shouldBind option.

If shouldBind is not part of the public api, do you have any other suggestion for solving my SO problem? Or should I open an issue to solve it? Forgive me if you have explained how to solve it above, your explanation of shouldBind was hard for me to understand.

evs-chris commented 7 years ago

I took a stab at it on SO, but I'm not certain it's any better 😄

lazylester commented 7 years ago

That helps a lot, Chris. Your help is very much appreciated. Thank you. From your SO response I was able to solve the problem in my app (and bump your SO rep!).

Should I leave this issue open as a reminder to document this binding behaviour? Or should I close it?