Skip to content

RFC: final API for 1.0.0 #127

@grych

Description

@grych

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.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions