You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for a nice & clean library.
One question (pardon if a silly one) is about this callback definitions:
defmodule Fsmx.Fsm do
...
if Code.ensure_loaded?(Ecto) do
@callback transition_changeset(struct, Fsmx.state_t, Fsmx.state_t) :: Ecto.Changeset.t()
@callback after_transition_multi(struct, Fsmx.state_t, Fsmx.state_t) ::
{:ok, struct} | {:error, any}
end
...
I thought the idea was to use @impl when overriding transition_changeset, like here:
defmodule App.StateMachineSchema do
# ...
@impl Fsmx.Fsm
def transition_changeset(changeset, "one", "two", params) do
# changeset already includes a :state field change
changeset
|> cast(params, [:data])
|> validate_required([:data])
end
but transition_changeset above accepts 4 params, while callback defines only 3 params.
Also there's no @behaviour in defmacro __using__.
This is not a bug report - just curious what was the original intent around @callback 🙏
The text was updated successfully, but these errors were encountered:
The purpose of this callback is indeed to override as you've done in your example. The callback definition was wrong and is fixed as part of other changes in #16 . But yes, by not having @behavior the callback definitions are merely informative and not being enforced.
If you'd like to open a pull request changing this, it could be a good first contribution, if you are interested.
Hey 👋
Thanks for a nice & clean library.
One question (pardon if a silly one) is about this callback definitions:
I thought the idea was to use
@impl
when overridingtransition_changeset
, like here:but
transition_changeset
above accepts 4 params, while callback defines only 3 params.Also there's no
@behaviour
indefmacro __using__
.This is not a bug report - just curious what was the original intent around
@callback
🙏The text was updated successfully, but these errors were encountered: