You'd be best splitting it up based on handlers, views and subs.
I don't think the top-level usage of register-handler and register-sub is a
good idea. I've been thinking about some options lately. The first would be
to define all your handler functions in separate files, i.e.
handlers/trip.cljs
handlers/vehicles.cljs
You could define the actual functions themselves, just not the register-handler.
Then in something like handlers/config.cljs, you would define some
configuration map that is a vector of vectors:
[ ; Top Level
[:path.to.handler/key 'handler-fn] ; Handler
[:vehicle.list/populate handlers.vehicles/populate-list]
]
Then in core.cljs, perhaps in the main function, you could call a function like
make-handlers:
(defn make-handlers [handlers]
(doseq [h handlers]
(apply register-handler h)))
(make-handlers handlers.config/config-vec)
Subs would work the same way.
The other option would be to define the configuration of the handlers, i.e. the
dispatch function identifier, and the actual handler function, and any
middleware within each of the handler files. So in this example, you would have
handlers.vehicles/config
handlers.trip/config
Then perhaps you have a top level config:
handlers.config/config-vec which concats all the separate configuration files.
core.cljs could then still call the make-handlers function using the
handlers/config.cljs
Subscriptions would work exactly the same.
Views would just be done in a top level such as
views/main
views/vehicles
views/trip
Views would choose their rendering functions based on the status of various
subscriptions and the state of the application.
It's a lot easier to configure handlers and subscriptions this way, making it
easier to test and substitute stub handlers or subs.
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.