This repository has been archived by the owner. It is now read-only.

Share internal identifiers and message types with the JavaScript client #117

Merged
merged 1 commit into from Nov 6, 2015

Conversation

Projects
None yet
4 participants
@javan
Member

javan commented Nov 6, 2015

Move internal messages to ActionCable::INTERNAL and sync window.Cable so we don't have to maintain them in two places.

cc: @lifo

@lifo

This comment has been minimized.

Member

lifo commented Nov 6, 2015

Looks great to me!

javan added a commit that referenced this pull request Nov 6, 2015

Merge pull request #117 from rails/shared-constants
Share internal identifiers and message types with the JavaScript client

@javan javan merged commit 63cdbf8 into master Nov 6, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@javan javan deleted the shared-constants branch Nov 6, 2015

@dchersey

This comment has been minimized.

dchersey commented on 365891d Nov 11, 2015

I am using this within a non-sprockets client app (ember-cli) talking to a rails backend.
Can you suggest the best way to include this client library in a way that has rails populate Cable.INTERNAL from the server as this change requires?

Thanks!

This comment has been minimized.

Member

javan replied Nov 12, 2015

Perhaps you can lean on your Rails backend to compile the cable js for you? How were you building the js before this commit?

This comment has been minimized.

dchersey replied Nov 12, 2015

This comment has been minimized.

Member

javan replied Nov 17, 2015

I'm not familiar with ember-cli or broccoli. Do they support Sprockets directives for requiring other files? https://github.com/rails/actioncable/blob/master/lib/assets/javascripts/cable/consumer.coffee#L1-L4 for example.

This comment has been minimized.

dchersey replied Nov 17, 2015

Ember-cli uses a completely different pipeline for assets, based on javascript. It's kind of 'rails-for-ember' in that it organizes your ember app according to convention-over-configuration and provides its own asset pipeline.

It uses a mix of bower, npm and broccoli for different purposes. The net-net though is that there's no ERB preprocessor so actioncable's embedding the internal references in cable.coffee.erb requires sprockets to be in the pipeline somewhere.

This effectively limits non-rails-based javascript UIs from being actioncable clients, and I wonder if that is worth gaining the value of injecting these internal values from the ruby code.

Fortunately for me, there is ember-cli-rails which serves ember-cli based clients via the rails asset pipeline -- after some fiddling and cursing I managed to get this working :)

This comment has been minimized.

Contributor

lsylvester replied Nov 18, 2015

I think that non sprockets asset manages will need to use precompiled versions of action cable where the erb and sprockets require directives have already been evaluated. I see no reason that a precompiled version of the cable javascripts couldn't be distributed for non rails users.

This comment has been minimized.

dchersey replied Nov 18, 2015

That's a good suggestion; perhaps that should go in the doc as well.
I'll give it a try if I move back to straight ember-cli (not served by rails) ... still debating pros/cons of that gem.

Previously to this commit I was including the js in the ember-cli asset pipeline; it was fine because it was all javascript and no ERB.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.