-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement observe/observe_deep
Unlike the original observe/observe_deep, it is not called in the middle of a transaction. It is called in the form of a process message after the transaction is completed.
- Loading branch information
Showing
25 changed files
with
1,804 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
defmodule Yex.ArrayEvent do | ||
@moduledoc """ | ||
Event when Array type changes | ||
@see Yex.Array.observe/1 | ||
@see Yex.Array.observe_deep/1 | ||
@see Yex.Map.observe_deep/1 | ||
""" | ||
defstruct [ | ||
:path, | ||
:target, | ||
:change | ||
] | ||
|
||
@type t :: %__MODULE__{ | ||
path: list(number() | String.t()), | ||
target: Yex.Array.t(), | ||
change: %{insert: list()} | %{delete: number()} | %{} | ||
} | ||
end | ||
|
||
defmodule Yex.MapEvent do | ||
@moduledoc """ | ||
Event when Map type changes | ||
@see Yex.Map.observe/1 | ||
@see Yex.Array.observe_deep/1 | ||
@see Yex.Map.observe_deep/1 | ||
""" | ||
defstruct [ | ||
:path, | ||
:target, | ||
:keys | ||
] | ||
|
||
@type change :: | ||
%{action: :add, new_value: term()} | ||
| %{action: :delete, old_value: term()} | ||
| %{action: :update, old_value: term(), new_value: term()} | ||
@type keys :: %{String.t() => %{}} | ||
|
||
@type t :: %__MODULE__{ | ||
path: list(number() | String.t()), | ||
target: Yex.Map.t(), | ||
keys: keys | ||
} | ||
end | ||
|
||
defmodule Yex.TextEvent do | ||
@moduledoc """ | ||
Event when Text type changes | ||
@see Yex.Text.observe/1 | ||
@see Yex.Array.observe_deep/1 | ||
@see Yex.Map.observe_deep/1 | ||
""" | ||
defstruct [ | ||
:path, | ||
:target, | ||
:delta | ||
] | ||
|
||
@type t :: %__MODULE__{ | ||
path: list(number() | String.t()), | ||
target: Yex.Map.t(), | ||
delta: Yex.Text.delta() | ||
} | ||
end | ||
|
||
defmodule Yex.XmlEvent do | ||
@moduledoc """ | ||
Event when XMLFragment/Element type changes | ||
@see Yex.Text.observe/1 | ||
@see Yex.Array.observe_deep/1 | ||
@see Yex.Map.observe_deep/1 | ||
""" | ||
defstruct [ | ||
:path, | ||
:target, | ||
:delta, | ||
:keys | ||
] | ||
|
||
@type t :: %__MODULE__{ | ||
path: list(number() | String.t()), | ||
target: Yex.Map.t(), | ||
delta: Yex.Text.delta(), | ||
keys: %{insert: list()} | %{delete: number()} | %{} | ||
} | ||
end | ||
|
||
defmodule Yex.XmlTextEvent do | ||
@moduledoc """ | ||
Event when Text type changes | ||
@see Yex.Text.observe/1 | ||
@see Yex.Array.observe_deep/1 | ||
@see Yex.Map.observe_deep/1 | ||
""" | ||
defstruct [ | ||
:path, | ||
:target, | ||
:delta | ||
] | ||
|
||
@type t :: %__MODULE__{ | ||
path: list(number() | String.t()), | ||
target: Yex.Map.t(), | ||
delta: Yex.Text.delta() | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.