Open SimonLab opened 5 years ago
The example is using behaviours to define the structure of the API interface: https://github.com/dwyl/phoenix-ecto-append-only-log-example/blob/e8eee00fab8f1555ab93c2d2757c497207d81873/lib/append/append_only_log.ex#L9-L14
The implementation of the API is then done in the before_compile macro: https://github.com/dwyl/phoenix-ecto-append-only-log-example/blob/e8eee00fab8f1555ab93c2d2757c497207d81873/lib/append/append_only_log.ex#L25-L48 ... However I'm not sure behaviours are needed for the append only example. From my understanding it makes sense to use behaviours when multiple modules need to provide the same functions but with a different logic of implemention. In our example only the AppendOnlyLog module is implementing the behaviours.
before_compile
AppendOnlyLog
For a learning purpose it makes sense to see how behaviours works :+1: but I'm not sure if they provide a lot of values for this repository?
Should we still keep them to demonstrate how they can be used?
ref: https://elixir-lang.org/getting-started/typespecs-and-behaviours.html#behaviours
Related to: https://github.com/dwyl/phoenix-ecto-append-only-log-example/issues/8
The example is using behaviours to define the structure of the API interface: https://github.com/dwyl/phoenix-ecto-append-only-log-example/blob/e8eee00fab8f1555ab93c2d2757c497207d81873/lib/append/append_only_log.ex#L9-L14
The implementation of the API is then done in the
before_compile
macro: https://github.com/dwyl/phoenix-ecto-append-only-log-example/blob/e8eee00fab8f1555ab93c2d2757c497207d81873/lib/append/append_only_log.ex#L25-L48 ... However I'm not sure behaviours are needed for the append only example. From my understanding it makes sense to use behaviours when multiple modules need to provide the same functions but with a different logic of implemention. In our example only theAppendOnlyLog
module is implementing the behaviours.For a learning purpose it makes sense to see how behaviours works :+1: but I'm not sure if they provide a lot of values for this repository?
Should we still keep them to demonstrate how they can be used?
ref: https://elixir-lang.org/getting-started/typespecs-and-behaviours.html#behaviours