Global object dependency in coconut


have question regarding coconut framework, maybe @back2dos or @kevinresol have some idea on this. I am trying to write coconut backend for framework where all views need access to root object in the constructor, sort of main object. What would be best way to solve such dependency ? In react there is context api where you can provide from the root some global dependencies.

Any ideas?

Thank you

There’s the @:implicit meta which is more or less equivalent to react context

Thank you @kevinresol will take a look

Yup, as Kevin said @:implicit would do the trick, although if it’s for backend framework specific stuff, it’s probably not the best way to go.

If this is based on coconut.diffing, then your implementation of cursor/applicator can probably take care of this in a simpler and more lightweight way.

@back2dos thank you will try to think how to initialise and pass that object through cursor, and will try to hide attribute from views

@back2dos finally got back to this, are there any example how to pass global dependency to cursor so it can be used as attribute, this framework what I use have global dependency for each visual element that need to be passed in constructor, idea was to remove it from attribute list and then manually add it inside backend

Mhhh, hard to tell. Is there any chance I could see the code you have so far? ^^

@back2dos sure will clean up a bit as just copied other backend as example, but in short
I have global object (WebglRenderingContext), thats is necessary for any view,

example new Node(context, props), would like to hide this context from user as it can / need to be created at init and then passed down for each view, ideally would like to have something like this

<Node position={[0, 0, 0]} /> and then that constructor context attribute could be populated from backend side. Not sure if its even possible but would like to find some solution.

Ok checked similar libs out there, most for them react based and they use context / hooks to share that webgl object