Gathering detailed insights and metrics for react-stompjs
Gathering detailed insights and metrics for react-stompjs
Gathering detailed insights and metrics for react-stompjs
Gathering detailed insights and metrics for react-stompjs
npm install react-stompjs
51
Supply Chain
94.9
Quality
74.2
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
8 Stars
9 Commits
2 Forks
1 Watching
1 Branches
1 Contributors
Updated on 01 Jun 2022
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-94.6%
2
Compared to previous day
Last week
-2.8%
70
Compared to previous week
Last month
6.3%
252
Compared to previous month
Last year
68.2%
3,527
Compared to previous year
1
React websocket High Order Component with @stomp/stompjs (V5) over SockJS
I need an updated STOMP client to work with latest version of React Native, it probably works in Browser as well.
It exposed the global STOMP client to the react components with HOC
It makes use of the great @stomp/stompjs for STOMP, check it's doc on how to use the Client
npm install react-stompjs --save
Import
1import {StompEventTypes, withStomp} from 'react-stompjs'
Connect your component withStomp(), it'll add stompContext into your component properties
1withStomp(App)
Now you can listen / remove the Stomp Events, ( check EventEmitter3 for emitted, context )
1const StompEventTypes = { 2 Connect: 0, 3 Disconnect: 1, 4 Error: 2, 5 WebSocketClose: 3, 6 WebSocketError: 4, 7} 8 9this.props.stompContext.addStompEventListener(eventType: StompEventTypes, emitted: function, context, isOnce) 10this.props.stompContext.removeStompEventListener(eventType: StompEventTypes, emitted: function, context)
And create/destroy the client
1this.props.stompContext.newStompClient(server_path, username, passcode, host) 2this.props.stompContext.removeStompClient()
You could access the Client directly ( Subscribe and unsubscribe etc )
1let rootSubscribed = this.props.stompContext.getStompClient().subscribe('/', (message) => {console.log(message.body)}) 2rootSubscribed.unsubscribe()
1import React, {Component} from 'react' 2import {Platform, StyleSheet, Text, View} from 'react-native' 3import {StompEventTypes, withStomp} from 'react-stompjs' 4 5class App extends Component { 6 constructor(props) { 7 super(props) 8 9 this.state = { 10 status: 'Not Connected', 11 } 12 } 13 14 componentDidMount(): void { 15 this.props.stompContext.addStompEventListener( 16 StompEventTypes.Connect, 17 () => {this.setState({status: 'Connected'})} 18 ) 19 this.props.stompContext.addStompEventListener( 20 StompEventTypes.Disconnect, 21 () => {this.setState({status: 'Disconnected'})} 22 ) 23 this.props.stompContext.addStompEventListener( 24 StompEventTypes.WebSocketClose, 25 () => {this.setState({status: 'Disconnected (not graceful)'})} 26 ) 27 this.props.stompContext.newStompClient( 28 {your_server_and_path}, // https://www.example.com/stomp 29 {username}, // loming 30 {passcode}, // 12345678 31 {host}) // it's '/' most likely 32 } 33 34 render() { 35 return ( 36 <View style={{flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#ffffff'}}> 37 <View><Text>Status: {this.state.status}</Text></View> 38 </View> 39 ) 40 } 41} 42 43export default withStomp(App)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/9 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More