Skip to content

Support for_option in the protocols macros #331

@GuillaumeMilan

Description

@GuillaumeMilan

Description of the feature

At the moment it is not possible to create operations you want to repeat in the protocols.
This could be handy for implementing set_cookies option to be able to set multiple cookie on the printing session.

Example:

defmodule MyApp.ProtocolExample do

  steps do
    for_options :set_cookies, ext:  :acc do
      call(:set_cookie, "Network.setCookie", &Map.fetch!(&1, :set_cookies_acc), %{httpOnly: true})

      await_response(:cookie_set, [])
    end
end

Implementation consideration

To be able to implement such a feature I am questioning myself on the following points:

  • Why steps are done through macros and not functions? While they are converted to function calls at the end
  • For the accumulator shall we save it inside the state? And if yes is there some standard to name keys (in the example I put it as :set_cookies_acc as the concatenation on set_cookies and acc as the extension.)

Also for the moment all the protocols system is not documented. Will it be part of a next iteration? (I am thinking it could be nice to make it part of a separated library)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions