View Source Yex.Map (y_ex v0.5.1)

A shareable Map type.

Summary

Functions

delete a key from the map.

get a key from the map.

set a key-value pair in the map.

Convert to json-compatible format.

Convert to elixir map.

Types

@type t() :: %Yex.Map{reference: any()}

Functions

delete a key from the map.

get a key from the map.

set a key-value pair in the map.

Convert to json-compatible format.

Examples Sync two clients by exchanging the complete document structure

iex> doc = Yex.Doc.new()
iex> map = Yex.Doc.get_map(doc, "map")
iex> Yex.Map.set(map, "array", Yex.ArrayPrelim.from(["Hello", "World"]))
iex> Yex.Map.set(map, "plane", ["Hello", "World"])
iex> assert %{"plane" => ["Hello", "World"], "array" => ["Hello", "World"]} = Yex.Map.to_json(map)

Convert to elixir map.

Examples

iex> doc = Yex.Doc.new()
iex> map = Yex.Doc.get_map(doc, "map")
iex> Yex.Map.set(map, "array", Yex.ArrayPrelim.from(["Hello", "World"]))
iex> Yex.Map.set(map, "plane", ["Hello", "World"])
iex> assert %{"plane" => ["Hello", "World"], "array" => %Yex.Array{}} = Yex.Map.to_map(map)