New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have an unified way of sending notifications #10
Comments
There has been some progress made in #7, so we can pick up some pieces from there and move ahead with any future changes. |
I think returning a list of errors along with the result would be tricky when it's One solution that I can think of is by returning the service and payload along with the error/success message. We can either return it in an array or pass it to the callback function that the user provided (this require a modification to |
@andreascm Oh yes, good catch. But I also believe that we could return the Or, maybe we'll need to separate out async and sync into |
I'm still new to Elixir. If we return I think |
@andreascm Yes, just to be clear, we don't execute the task on our own, the task is created through the supervisor. The returned result looks like this: {:ok, %Task{owner: #PID<0.250.0>, pid: #PID<0.251.0>, ref: #Reference<0.0.1.123>}} Since the created task is returned, users can choose these options for executing the task:
task_pid = Task.start(task)
task_result = Task.await(task) Mostly people would use {status, task} = Notifiex.send_async(:mock, %{hello: "world"}, %{})
task_result = Task.await(task)
# task_result is returned as this:
{:ok, true} Here's a list of various things you can do with tasks. I do agree that the semantics here differ from other languages, and since this was my first Elixir project, I was hesitant with this approach too; but I've seen this pattern being followed in other Elixir projects too. If you have a better alternative, I'd love to hear that! |
Currently
notifiex
has multiple functions to send notifications; however, we could improve it by refactoring to a single function which accepts things like a list of services to send, type (async/sync), etc. Expected usage would be similar to this:Things to note:
send_multiple/1
andsend_async_multiple/1
now or sometime later.The text was updated successfully, but these errors were encountered: