Periscope (periscope v0.5.6)

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

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

deep_has_key?(map, key)

@spec deep_has_key?(map(), atom()) :: boolean()

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.

Link to this function

is_a_liveview_route?(route)

@spec is_a_liveview_route?(atom() | map()) :: boolean()

Takes a route and returns true if it's a route to a liveview module.

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

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.

Link to this function

schema_fields(schema_module)

@spec schema_fields(binary()) :: list()

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

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.