Skip to content
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

Ported simple.js to coffeescript #28

Merged
merged 4 commits into from
Feb 25, 2015

Conversation

jvelliott
Copy link

Tried to do a direct conversion to help any other noobs out there trying to learn coffeescript.

A couple list comprehensions. Not sure if there's a nicer way to do ternary in coffeescript?

@jvelliott jvelliott force-pushed the coffeescript-example branch 3 times, most recently from f201458 to e103330 Compare February 20, 2015 09:50
@evansolomon
Copy link
Contributor

Your coffeescript "ternary" is generally right in that you're using an if/else as an expression. The maybe "nicer" way would be to one line it: result = if condition then truthyResult else falselyResult

I'll leave a couple other comments on your commit with some more coffeescript tips (not that anything you did was wrong).

channel = slack.getChannelGroupOrDMByID(message.channel)
user = slack.getUserByID(message.user)
time = message.ts
text = message.text
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a nice desctructuring syntax in cs: {type, ts, text} = message

@jvelliott
Copy link
Author

Thanks for the feedback. I'll update it over the weekend.

Do you prefer I make a separate commit, or rebase onto this one?

@evansolomon
Copy link
Contributor

Do you prefer I make a separate commit, or rebase onto this one?

Whatever you like.

I think it also makes sense to actually replace the JS version. Having both in the source, especially when they're not actually the "same" code, seems confusing. To do that it should be added to the grunt prepublish build step.

@@ -0,0 +1,73 @@
#!/usr/bin/env coffee
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this unless the file is meant to be executable (which it probably shouldn't be).

@jvelliott
Copy link
Author

I think it also makes sense to actually replace the JS version.

OK, that sounds good to me. Should I go through and comment on the new compiled version, or just leave it alone?

You do actually want it committed, right?

@evansolomon
Copy link
Contributor

Let's not commit the compiled JS. It can be compiled by the same grunt task that handles the rest of the library. So the JS file should also be removed from Git and gitignored.

Let me know if any of that doesn't make sense or if you want any help.

cwd: 'examples'
src: ['*.coffee']
dest: 'examples'
ext: '.js'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope this looks good. Never worked with grunt before!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jtatum
Copy link
Contributor

jtatum commented Feb 23, 2015

Not sure if this belongs here, but there was something I was going to poke at the sample code about. There are a variety of things that will crash the javascript sample, like deleting a message. Some 'message' subtypes have no user or text associated with them so the console.log throws.

@jvelliott
Copy link
Author

Hah, it's a fair point. Guess I never noticed that deleting/editing/a bunch of other stuff all hits the on "message" callback.

Seems to me like either the project or the APIs are being pretty overbroad with those things, but it can't hurt to do a bit of null checking.

After some experimenting.. it looks like message.subtype is not set when it's a normal message, but that doesn't feel like a safe condition to reason on.

@evansolomon
Copy link
Contributor

@jvelliott is this all ready to merge?

@jvelliott
Copy link
Author

As far as I know!

@jvelliott jvelliott force-pushed the coffeescript-example branch from e223ead to 68d6b1a Compare February 25, 2015 17:25
James Elliott added 4 commits February 25, 2015 12:09
Better explanation on how to run simple_reverse.coffee example
Added examples to the Gruntfile
Responded to issues from code review.
New, better variable names in comprehensions.
@jvelliott jvelliott force-pushed the coffeescript-example branch from 68d6b1a to 03ad8a7 Compare February 25, 2015 20:09
@jvelliott
Copy link
Author

Rebased commits so they all show up together after merge.

evansolomon added a commit that referenced this pull request Feb 25, 2015
@evansolomon evansolomon merged commit 22f35df into slackapi:master Feb 25, 2015
@evansolomon
Copy link
Contributor

Thanks!

aoberoi added a commit to aoberoi/node-slack-sdk that referenced this pull request Mar 20, 2019
adds SlackEventAdapter.stop() method
aoberoi added a commit to aoberoi/node-slack-sdk that referenced this pull request Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants