Periscope (periscope v0.6.0)
Tools for dealing with liveview processes, components, sockets, assigns. Pulls this information directly from the list of BEAM processes.
Link to this section Summary
Functions
Returns a list of liveview module names. Expect to see stuff like MyApp.CustomerWorkflow or some such name. This does NOT list the names of components. Use components/0 for that.
Returns the sockets for all active liveviews in a 0-indexed map. So all_sockets(0) will return the first socket in the map.
Returns the assigns for the fully-qualified component name, e.g. assigns_for(MyappWeb.MainView.Table) will return the assigns for that component.
Returns a list of active component names. These are module names, so you only see one per module. Even if one component is rendered many times, you will only see its name once. If you want to see how many instances of a component are rendered. use components/0.
Returns a map whose keys are component names (as those found in component_names) and whose values are the assigns for those components.
Searches through a nested map (such as socket.assigns) and checks if key
exists at any point in the tree. Useful for finding out if a given key is somewhere in your assigns without scrolling through pages of socket info.
Takes a route and returns true if it's a route to a liveview module.
liveview_pids returns the PID of every process if that process contains a liveview.
Will return a map that takes liveviews to lists of paths to those views. Useful if you want to access a component fast without having to scroll through the router and figure out its URL.
Takes the last part of a schema module name and returns all the fields in that schema. So running schema_fields("Comments")
in an app called MyBlog will return all fields for MyBlog.Schemas.Comments..
Returns a single socket. You can access the assigns using socket.assigns. However, socket.assigns will not show the assigns on the components (see component_names).
as socket/1, but for liveview names.
Link to this section Functions
all_liveviews()
@spec all_liveviews() :: [module()] | []
Returns a list of liveview module names. Expect to see stuff like MyApp.CustomerWorkflow or some such name. This does NOT list the names of components. Use components/0 for that.
all_sockets()
@spec all_sockets() :: map()
Returns the sockets for all active liveviews in a 0-indexed map. So all_sockets(0) will return the first socket in the map.
assigns_for(component)
Returns the assigns for the fully-qualified component name, e.g. assigns_for(MyappWeb.MainView.Table) will return the assigns for that component.
component_names()
@spec component_names() :: list()
Returns a list of active component names. These are module names, so you only see one per module. Even if one component is rendered many times, you will only see its name once. If you want to see how many instances of a component are rendered. use components/0.
Note that components have their own assigns. If you want to see the assigns for a component, you can use assigns_for/1.
components_to_assigns()
@spec components_to_assigns() :: map()
Returns a map whose keys are component names (as those found in component_names) and whose values are the assigns for those components.
deep_has_key?(map, key)
Searches through a nested map (such as socket.assigns) and checks if key
exists at any point in the tree. Useful for finding out if a given key is somewhere in your assigns without scrolling through pages of socket info.
is_a_liveview_route?(route)
Takes a route and returns true if it's a route to a liveview module.
liveview_pids()
@spec liveview_pids() :: [pid()] | []
liveview_pids returns the PID of every process if that process contains a liveview.
liveviews_to_paths()
@spec liveviews_to_paths() :: list()
Will return a map that takes liveviews to lists of paths to those views. Useful if you want to access a component fast without having to scroll through the router and figure out its URL.
schema_fields(schema_module)
Takes the last part of a schema module name and returns all the fields in that schema. So running schema_fields("Comments")
in an app called MyBlog will return all fields for MyBlog.Schemas.Comments..
socket(socket_index \\ 0)
@spec socket(non_neg_integer()) :: map()
Returns a single socket. You can access the assigns using socket.assigns. However, socket.assigns will not show the assigns on the components (see component_names).
which_liveview(socket_index \\ 0)
@spec which_liveview(non_neg_integer()) :: map()
as socket/1, but for liveview names.