(apply-route-change reporter route-params app-db-atom commands-chan controllers)
(apply-start-or-wake-controllers action
reporter-action
app-db
reporter
controllers
commands-chan
get-running
active-topics
start-or-wake)
(call-handler-on-started-controllers app-db-atom reporter start)
(call-ssr-handler-on-started-controllers app-db-atom
reporter
start
ssr-handler-done-cb)
(route-change-execution-plan route-params running-controllers controllers)
(send-route-changed-to-surviving-controllers app-db-atom
reporter
route-changed
route-params)
(start route-chan
route-processor
commands-chan
app-db-atom
controllers
reporter)
Starts the controller manager. Controller manager is the central part of the application that manages the lifecycle of the controllers and routes the messages sent to them.
start
function receives the following parameters:
route-chan
- Route changes will communicated through this channelroute-processor
- Function that will be called on every route change. It can be used to process the route before it's written into app-dbcommands-chan
- User (UI) commands will be sent through this channelapp-db
- application state atomcontrollers
map of controllers registered for the appreporter
- internal reporter functionEach time when the new route data comes through the route-chan
controller
manager will do the following:
params
function on each registered controllerparams
function with the value that
was returned last time when the route changesnil
and the current value is nil
- do nothingnil
and the current value is not nil
- start the controllernil
and the current value is nil
- stop the controllernil
and the current value is not nil
and these values are the same - do nothingnil
and the current value is not nil
and these values are different - restart the controller (stop the current instance and start the new one)Controller manager also acts as a command router. Each time a command comes - through the commands-chan
the name of the command should look like this [:controlnler-key :command-name]
. Controller manager will route the :command-name
command to the appropriate controller based on the :controller-key
. Controller key is the key under which the controller was registered in the controllers
argument.
Starts the controller manager. Controller manager is the central part of the application that manages the lifecycle of the controllers and routes the messages sent to them. `start` function receives the following parameters: - `route-chan` - Route changes will communicated through this channel - `route-processor` - Function that will be called on every route change. It can be used to process the route before it's written into app-db - `commands-chan` - User (UI) commands will be sent through this channel - `app-db` - application state atom - `controllers` map of controllers registered for the app - `reporter` - internal reporter function Each time when the new route data comes through the `route-chan` controller manager will do the following: - call the `params` function on each registered controller - compare the value returned by the `params` function with the value that was returned last time when the route changes - based on the comparison it will do one of the following: - if the last value was `nil` and the current value is `nil` - do nothing - if the last value was `nil` and the current value is not `nil` - start the controller - if the last value was not `nil` and the current value is `nil` - stop the controller - if the last value was not `nil` and the current value is not `nil` and these values are the same - do nothing - if the last value was not `nil` and the current value is not `nil` and these values are different - restart the controller (stop the current instance and start the new one) Controller manager also acts as a command router. Each time a command comes - through the `commands-chan` the name of the command should look like this `[:controlnler-key :command-name]`. Controller manager will route the `:command-name` command to the appropriate controller based on the `:controller-key`. Controller key is the key under which the controller was registered in the `controllers` argument.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close