-
Notifications
You must be signed in to change notification settings - Fork 60
Re-wrote Component to be more modern #14
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
base: master
Are you sure you want to change the base?
Conversation
… hooks and better tooling"
|
This requires a bit more work, but I made the PR to propose the new structure. Otherwise, I have package this as |
cpunion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need update
src/ActionCableProvider.jsx
Outdated
| this.componentWillUnmount(); | ||
|
|
||
| // create or assign cable | ||
| this.componentWillMount(); |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/ActionCableProvider.jsx
Outdated
| class ActionCableProvider extends Component { | ||
| constructor(props) { | ||
| super(props); | ||
| this.displayName = 'ActionCableProvider'; |
There was a problem hiding this comment.
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
|
All the requested changes have been made, and some additional improvements that were necesary. |
|
Thanks! I will review and test later. |
| } | ||
| Cable.propTypes = { | ||
| channel: PropTypes.string.isRequired, | ||
| room: PropTypes.string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does room means?
There was a problem hiding this comment.
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 />); |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
|
Thanks for your great work. That's big changes, I need more time to test. |
|
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. |
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
installhook, but i believe it is better to use thepreparehook instead. This require update of the documentation as well, I can do this when i have a bit more free time.To Do: