-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Slack has a bunch of HTTP RPC-style methods, and it seems likely that users of Slacker will want to make use of them. As the token is already known to Slacker, it should be simple to provide a handy wrapper for calling the methods.
Some usage ideas:
1. Return a plain Clojure map
This would be a blocking call and returns everything from the server.
(slacker.method/emoji-list)
{:ok true,
:emoji
{:bowtie "https://my.slack.com/emoji/bowtie/46ec6f2bb0.png",
:squirrel "https://my.slack.com/emoji/squirrel/f35f40c0e0.png",
:shipit "alias:squirrel"}}2. Return a promise-chan (non-blocking)
This would be a non-blocking call, and everything from the server would be put on the promise-chan when available. As a "rejected" promise-chan only contains nil, there's no way to communicate error messages, which is annoying.
(if-let [emojis @(slacker.method/emoji-list)]
emojis
:scary-error)3. Register success and error handlers (non-blocking)
This would make use of the :ok value in the map to determine whether to call the success or error handler. It would pass on the content to the success-fn and the error to the error-fn. In both cases this seems to be just the map with the :ok key removed.
(slacker.method/emoji-list success-fn error-fn)