This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
@greenhorse: sure, so what I have done is broken my application down into a set of DSL's (blaze is a blogging DSL) these define a bunch of vars with
^:dynamic meta data on them, this lets me bind a new ref to this var at runtime, what this allows me to do is program against these vars without them containing a real reference (they can contain a default), in my index page I use bindings to tie these together, which means anything can be removed or replaced by adjusting the bindings instead of recoding all the references
It also allows me to break up my application into libraries, as long as the libraries implement the dynamic refs, they are unaware of each other, and do not rely on each other, even tho many of them may reference my database for example
Oh it might be worth mentioning that bindings allow 'pass through' between functions, so I don't need to directly pass a reference through my functions, they just know about the refs based on the thread binding
So if I know my database will give me a formula cell I can work with that, and then just swap the binding when I change database providers
No recoding needed, all my libraries assume that the db provider will give me a cell with the correct data
the browser is a multithreaded environment from the point of view of overall program design
an example of what i mean by component scope: https://gist.github.com/micha/032367265649dee391b09f6cd456d3ea
inside of that scope there are various other nested components whose attributes get their default values from the dynamic scope
this means that a nested component can be inside another component that doesn't know aobut the data
like in the example, the
form/validation-message component gets its configuration from dynamic scope, which gives it access to the workflow state machine for instance
and also it gets the specific field for which it will display validation messages from the
notice how the
:state attribute can be overridden, but it gets its default value from the dynamic scope
can I take a look at the with-field macro also ? 🙂 or just a general idea what it does?
those are just really some syntax sugar around
cljs.core/binding that i personally like
@micha do the bindings need to exist in a namespace to be able to set them in
binding? I noticed yours don't have namespaces
they're in the same namespace at compile time, they're in the cljs file that defines the same namespace in cljs
expanding macros at compile time in clojure to generate code that runs in clojurescript later is confusing sometimes
yeah, I read @alandipert post on cljs macro’s the other day, that was one of the light bulbs you gave me was that macro’s didn’t work the way in cljs I was expecting.
@flyboarder it probably got answered. Unfortunately it's above my current level. But I kinda understand the idea. Tried to follow the code but it's not easy (for me). The code itself looks beautiful though. Great job!
this is a large application that we'll be maintinaing for a long time, so it pays to make it nice 🙂
im my code I provide the option to also pass in local state everywhere as an alternative, so if the bindings don’t work or get confusing for whatever reason you can just ignore it, like click handlers for example
yeah that's an important point, you need to be able to override all the dynamic things via direct attributes on the elements when you want to
that's another example, you can see all the forms use the same components throughout the application