Skip to content

Conversation

@jediofthecode
Copy link

@jediofthecode jediofthecode commented Apr 24, 2018

I re-wrote the base Provider component to use the more modern syntax. I also re-write the component completely, to be a HOC instead. I also improved the build process of the plugin itself. The build process requires some review, I used the install hook, but i believe it is better to use the prepare hook instead. This require update of the documentation as well, I can do this when i have a bit more free time.

To Do:

  • Rewrite new tests to adhere to new plugin structure
  • Update documentation to coincide with the new usage, and provide more detailed API usage

@jediofthecode
Copy link
Author

This requires a bit more work, but I made the PR to propose the new structure. Otherwise, I have package this as react-actioncable-provider-next for testing

Copy link
Owner

@cpunion cpunion left a comment

Choose a reason for hiding this comment

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

Need update

this.componentWillUnmount();

// create or assign cable
this.componentWillMount();
Copy link
Owner

Choose a reason for hiding this comment

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

componentWillMount use this.props, but in this context, must re-subscribe with nextProps

package.json Outdated
{
"name": "react-actioncable-provider",
"version": "1.0.3",
"name": "react-actioncable-provider-next",
Copy link
Owner

Choose a reason for hiding this comment

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

Don't update name, urls in PR, you can add your name as contributors.

Copy link
Author

Choose a reason for hiding this comment

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

Apologies, this was only to publish the package with a new name, as I needed to include it in a project im working on. I will revert this and push on my branch.

class ActionCableProvider extends Component {
constructor(props) {
super(props);
this.displayName = 'ActionCableProvider';
Copy link
Owner

Choose a reason for hiding this comment

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

I think the instance variable displayName is unused.

  - Added support for updating channel name and room on
    component(Component will now automatically re-initialize cable
    connection)
  - Improved documentation surrounding new format
  - Reverted package.json to older values
  - Update ActionCableProvider component with suggested fixes
@jediofthecode
Copy link
Author

All the requested changes have been made, and some additional improvements that were necesary.
This should also fix #12

@cpunion
Copy link
Owner

cpunion commented Apr 27, 2018

Thanks! I will review and test later.

}
Cable.propTypes = {
channel: PropTypes.string.isRequired,
room: PropTypes.string
Copy link
Owner

Choose a reason for hiding this comment

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

What does room means?

Copy link
Author

Choose a reason for hiding this comment

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

room is the room parameter that can be passed into the channel 'controller', it is from the ActionCable guide.

import ActionCableProvider, { cable } from '../index';

test('Render wrapped component without children', () => {
const Wrapped = cable(<div />);
Copy link
Owner

Choose a reason for hiding this comment

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

I think the first parameter of cable should be a Component, not an instance.

}

render () {
render() {
Copy link
Owner

@cpunion cpunion May 1, 2018

Choose a reason for hiding this comment

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

Can't use ActionCable component in the following anymore.

config.room = room;
}

this.cable = this.context.cable.subscriptions.create(config, eventHandlers);
Copy link
Owner

Choose a reason for hiding this comment

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

Rename this.cable to this.subscriptions more accurate.

}

// cable is created by self, disconnect it
this.componentWillUnmount();
Copy link
Owner

Choose a reason for hiding this comment

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

Wrap to a better name?

@cpunion
Copy link
Owner

cpunion commented May 1, 2018

Thanks for your great work. That's big changes, I need more time to test.

@jediofthecode
Copy link
Author

Sorry for the delay, i have been quite busy. I will try and get these changes in this, and I made some other fixes in the mean time that were crucial.

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.

2 participants