View Source Bonfire.Common.ExtensionBehaviour behaviour (Bonfire v0.9.10-classic-beta.169)
A Global cache of known Behaviours in Bonfire
Use of the ExtensionBehaviour Service requires declaring @behaviour Bonfire.Common.ExtensionBehaviour
in your behaviour module. This module will then index those behaviours and all the modules that implement those behaviours at app startup.
While this module is a GenServer, it is only responsible for setup of the cache and then exits with :ignore having done so. It is not recommended to restart the service as this will lead to a stop the world garbage collection of all processes and the copying of the entire cache to each process that has queried it since its last local garbage collection.
Summary
Functions
Given a behaviour module, filters app modules to only those that implement that behaviour
Note: use apply_modules_cached/2
instead, as it caches the result.
Runs/applies a given function name on each of a list of given modules, returning a map (listing the modules with their result as value) and vice versa (listing the results as key with their calling module as value). It also caches the result on first run.
Returns a specification to start this module under a supervisor.
Populates the global cache with config_module data via introspection.
Callbacks
@callback modules() :: any()
List modules that implement a behaviour
Functions
adopters_of_behaviour(behaviour \\ __MODULE__, app_modules_to_scan \\ app_modules_to_scan())
View SourceGiven a behaviour module, filters app modules to only those that implement that behaviour
Note: use apply_modules_cached/2
instead, as it caches the result.
Runs/applies a given function name on each of a list of given modules, returning a map (listing the modules with their result as value) and vice versa (listing the results as key with their calling module as value). It also caches the result on first run.
Returns a specification to start this module under a supervisor.
See Supervisor
.
find_adopters_of_behaviours(behaviours \\ find_extension_behaviours(), app_modules_to_scan \\ app_modules_to_scan())
View Sourcefind_extension_behaviours(app_modules_to_scan \\ app_modules_to_scan())
View Source@spec start_link(ignored :: term()) :: GenServer.on_start()
Populates the global cache with config_module data via introspection.