Periscope (periscope v0.7.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.

liveview_pids returns the PID of every process if that process contains a liveview.

Used for testing handle_info/2 callback.

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

Link to this function

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.

@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.

Link to this function

assigns_for(component)

@spec assigns_for(binary()) :: map()

Returns the assigns for the fully-qualified component name, e.g. assigns_for(MyappWeb.MainView.Table) will return the assigns for that component.

Link to this function

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.

Link to this function

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.

Link to this function

liveview_pids()

@spec liveview_pids() :: [pid()] | []

liveview_pids returns the PID of every process if that process contains a liveview.

Link to this function

message(msg, socket_number \\ 0)

Used for testing handle_info/2 callback.

Link to this function

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).

Link to this function

which_liveview(socket_index \\ 0)

@spec which_liveview(non_neg_integer()) :: map()

as socket/1, but for liveview names.