-
Notifications
You must be signed in to change notification settings - Fork 595
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
Using Choo to create reusable widgets? #309
Comments
Thanks! - Yeah, I think this should be possible: probably wanna turn off On Thu, Nov 3, 2016 at 11:30 PM Debbie Facey [email protected]
|
OK. So you saying it possible that future version of choo would not required the router? |
Oh you can already disable these things; there's no way to take out the On Thu, Nov 3, 2016 at 11:58 PM Debbie Facey [email protected]
|
Hey I did something similar in my app, I have a wrapper utility function that injects child views into a parent view, that way I can separate my components from a parent template view and still use the router. It also allows my setup a pre-route and post route hook. I can also have different parent views for different routes like different layouts if i want.
main.js
child.js
app.js
|
@rollymaduk. That's a nice pattern, but doesn't really answer my question. I want to be able to essentially use a choo created element outside of a choo application. Just basically drop it on any page and be able to communicate with it via both handling events triggered from within the element as well as manually triggering actions. It is the latter that I asking about. @yoshuawuyts I think I need to clarify a bit more. i.e. What if I want to trigger an action programmatically from outside? In the code snippet below, I've exposed an As I said, it works but not very clean. Just wondered if there is a better way.
|
I see what you mean, perhaps in order to create a more generic send you could just avoid the closure and expose the send from your main view assigned to a variable on your returned tree element... havent tried it but I suspect it might work.
|
@rollymaduk Thanks so much! This fits my needs exactly. At a glance, it appears the API may have changed slightly since you posted this, so in case anyone else is interested I've added an example that works for me with 4.0.1 here The only other note is that |
Were you able to resolve this? |
@yoshuawuyts was that a question for me or in response to the above? I hate to hijack the issue with my concerns simply because I was the last to comment. 😄 Edit: Rereading, yeah, just checking with the original poster for closability. Describing the below since after trying a couple different approaches, I just deleted what I didn't need from choo and found the remaining part to be concise and useful for a self-contained widget! Probably the way I'd do it if I hadn't run into the other snag. FWIW though, my goal with choo is to recreate a control widget more modern and feature-complete than dat.gui and perhaps a bit too divergent from control-panel to simply keep building on that. React is too big; plain JS is too ad-hoc. Choo seems perfect. Taking a slightly different tack, I got as far as distilling choo down to choo-lite.js and built this. I got hung up on this yo-yo issue in which what seems like a weird browser quirk negates some of the simplicity for which I was aiming. Haven't yet figured out how to work around it, but everything else about the approach works for me! |
Yay, glad to hear! Re: your issue - we're currently working on nanomorph;
perhaps that yields a better result?
https://github.com/yoshuawuyts/nanomorph
…On Sun, Jan 8, 2017 at 8:20 PM Ricky Reusser ***@***.***> wrote:
@yoshuawuyts <https://github.com/yoshuawuyts> was that a question for me
or a general question? I hate to hijack the issue with my concerns simply
because I was the last to comment. 😄
FWIW though, my goal with choo is to recreate a control widget more modern
and feature-complete than dat.gui
<https://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage> and
perhaps a bit too divergent from control-panel
<https://github.com/freeman-lab/control-panel/> to simply keep building
on that. React is too big; plain JS is too ad-hoc. Choo seems perfect.
Taking a slightly different tack, I got as far as distilling choo down to
choo-lite.js
<https://github.com/rreusser/control-panel-2/blob/master/src/choo-lite.js>
and built this <http://rreusser.github.io/control-panel-2/>.
I got hung up on this issue <max-mapper/yo-yo#56>
in which what seems like a weird browser quirk negates some of the
simplicity for which I was aiming. Haven't yet figured out how to work
around it, but everything else about the approach works for me!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#309 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACWleqJSwuHr6CbjzJCTXUrq9Bsz3jQZks5rQTbogaJpZM4Ko8Mc>
.
|
Although super early stages, this might be useful. https://github.com/ohgoodlord/choo-component Suggestions welcome! |
Nice work! Consider adding this to the awesome-choo repo ✨
…On Sat, Jan 21, 2017, 11:02 Joseph Luck ***@***.***> wrote:
Although super early stages, this might be useful.
https://github.com/ohgoodlord/choo-component
Suggestions welcome!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#309 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACWlegKEPP-w23iIPWmPrMv0fXgyt6iKks5rUde2gaJpZM4Ko8Mc>
.
|
We should probably document this a bit further in the handbook, but https://www.npmjs.com/package/nanocomponent is a thing now ✨ |
I wanted to see if I could use choo to create a widget that I can add to any HTML page. I had the following requirements:
Was choo built to handle this? I noticed that all examples require the router to configured for example. I would not need this and I am interested to know if choo can be used without it. What I would want to use is the model and the view functionality.
I hacked together a POC of how this could be done. You can look at the jsbin here. It works but, as I said it's kind of hacky. My problem was really that I needed to get access to the
send
function, to be able to attach it to the element instance, in order to be able to call a function on the rendered element. The only way I could think to do it was to expose thesend
function outside of the main view.So, is there a better way?
By the way, great framework. It's really fun!
The text was updated successfully, but these errors were encountered: