Drab: Getting valid assigns for the current socket?

Is there a way to get a list (or other datatype) of valid live assigns for the current socket/commander? I’ve found a few things like Drab.Live.HTML.amperes_from_buffer, etc., but I’m not sure which internal API functions I could stitch together to get this information.

I’m not really asking for production use at the moment, even though that’s potentially interesting also, but rather for a PR that I’m working on that could introduce some ease of first use.

1 Like

There is no API for that.

Unofficially, you might do

socket |> Drab.pid() |> Drab.get_priv() |> Map.fetch(:__ampere_assigns)

and you’ll get a map

%{"partial_code" => %{"assign1" => "encrypted value", "assign2" => "encrypted value...}

but as this are internal functions, so it is not guaranteed it will work in every release :slight_smile:


Anyway, it is easy to create a function in Drab.Live returning the list of assigns. If you need it, pls create an issue on gituhub, so it will not be forgotten :slight_smile:

2 Likes

I made a PR instead of an issue, I hope that’s preferable.

2 Likes