This is a proposed API for v1.0.0.
The most significant change would be for negative return of all the functions, now it is {:error, reason} or {:timeout, reason}, will be {:error, reason}, where reason could be :timeout.
The breaking change is also the return value of Drab.Live.peek. Now it just returns the value of the asssign, where it should get {:ok, value} tuple.
Drab.Core
| Function |
Current return |
Proposed return |
exec_js/3 |
{:ok, value}, {:error, reason}, {:timeout, message} |
{:ok, value}, {:error, reason}, {:error, :timeout}, {:error, :disconnected} |
exec_js!/3 |
Value, or raise Drab.JSExecutionError |
Value, or raise distinguishable: Drab.JSExecutionError, Drab.DisconnectedError |
Drab.Element
All functions return exactly the same as Drab.Core. DOM modifying functions (set_prop) return {:ok, number_of_modifed_elements} or {:error, reason}
Drab.Live
| Function |
Current positive return |
Current negative return |
Proposed positive return |
Proposed negative return |
poke |
%Phoenix.Socket{} |
return of exec_js |
{:ok, integer} |
return of exec_js |
peek |
value of the assign |
return of exec_js |
{:ok, value_of_the_assign} |
return of exec_js |
poke! |
N/A, new function |
N/A, new function |
integer |
raises exception as exec_js! |
peek! |
N/A, new function |
N/A, new function |
value of the assign |
raises exception as exec_js! |
where integer is a number of operations done on the browser.
Drab.Browser
All functions returns new negative pattern of exec_js.
Drab.Waiter
No changes.
Drab.Query
I am not planning to do any changes there, because even it is not very idiomatic, I find this API nice and readable.
Drab.Modal
No changes.
This is a proposed API for v1.0.0.
The most significant change would be for negative return of all the functions, now it is
{:error, reason}or{:timeout, reason}, will be{:error, reason}, wherereasoncould be:timeout.The breaking change is also the return value of
Drab.Live.peek. Now it just returns the value of the asssign, where it should get{:ok, value}tuple.Drab.Core
exec_js/3{:ok, value},{:error, reason},{:timeout, message}{:ok, value},{:error, reason},{:error, :timeout},{:error, :disconnected}exec_js!/3Drab.JSExecutionErrorDrab.JSExecutionError,Drab.DisconnectedErrorDrab.Element
All functions return exactly the same as
Drab.Core. DOM modifying functions (set_prop) return{:ok, number_of_modifed_elements}or{:error, reason}Drab.Live
poke%Phoenix.Socket{}exec_js{:ok, integer}exec_jspeekexec_js{:ok, value_of_the_assign}exec_jspoke!integerexec_js!peek!exec_js!where integer is a number of operations done on the browser.
Drab.Browser
All functions returns new negative pattern of
exec_js.Drab.Waiter
No changes.
Drab.Query
I am not planning to do any changes there, because even it is not very idiomatic, I find this API nice and readable.
Drab.Modal
No changes.