Synthetic event types -- event types that are deduced from combinations of event properties
We can infer some missing event types by looking at event.type + event.subtype , e.g.
if (type === 'message') {
if (subtype === 'message_changed') // message_changed
else if (! subtype) // message_created
}
Backwards works too -- going from specific to generic, e.g.
if (type === 'reaction_added' || type === 'reaction_removed') // reaction_changed
Would you be willing to add such event types this to this library?
Thanks in advance.
interesting idea!
in the first example (going generic to specific) the risk is that if the underlying types evolve to include more specific types, the assumptions could break. imagine a new subtype called "message_shared" starts to exist, now the result is a "message_created" event that is just not true.
The second example seems less risky to me -- the underlying types are not likely to become less specific so the assumptions will hold true.
i'm not dismissing the idea, but maybe we can refine it to try and mitigate the risks.
Thank you for the quick response.
Your argument for the first example doesn't hold.
The code checks subtype for falsy,
hence adding message_shared would "return" undefined.
But I see your point, we can't guarantee Slack's API won't change in unexpected ways. I would much rather prefer this to be implemented by Slack's API. Can you make that happen, @aoberoi?
Thank you.
Hah okay, you're right my example was poorly constructed. The example should have been something where the new subtype might also mean "message_created" but isn't called that. But it sounds like we're on the same page.
I can surely take feedback on the API. Which event subtypes are you specifically interested in?
Currently this adapter doesn't try to do anything with subtypes, how would you feel about a syntax to work with subtypes? Here's an idea:
// use 'type:subtype' to specify the subtype
slackEvents.on('message:message_changed', () => {});
// use 'type:_' to specify the absence of a subtype
slackEvents.on('message:_', () => {});
To answer your question, I'm interested in:
- the subtype
message_created - the type
reaction_changed
Am all in favor of the new extended syntax. When can you get started?
NB: A subtype message_created would be simpler, however a breaking change.
Am willing to open a PR but I'd need to know from you that
- You're willing to accept it
- You're not already working on it
Naturally, I'd prefer you implement it yourself :-)
Thanks!
thanks @gunar! if we're talking about the new subtype syntax, the answers are yes i'm willing to accept it and no i'm not already working on it.
i haven't prioritized this high against the other work i'm doing so that means it would be at least a couple weeks before i get around to it. if could produce it sooner though, i'm happy to merge and release!
@gunar still interested in working on this one?
Not at this moment.
I've reopened under the new parent package at https://github.com/slackapi/node-slack-sdk/issues/820. Feel free to continue the conversation there 😄