jonnybgod / react-native-eventsource Goto Github PK
View Code? Open in Web Editor NEWA react-native component for EventSource: Server-Sent Events for iOS and Android
A react-native component for EventSource: Server-Sent Events for iOS and Android
When I try to open a stream, it fails with this error:
Cannot read property 'connect' of undefined at EventSource.connectToSourceImpl
iOS & Android
Expo 15 & RN 0.42 January
sse has more than a data
field. It can include an event
, or id
(amongst some others). event
in this lib should conform sse events.
After updating the react-native version, I'm getting error like this one:
Conflicting types for 'objc_getAssociatedObject'
Similar problem (and solution) reported here.
Hello! I'm trying to use your module to get SSE from YouTrack service.
But the only message I receive is with type "ping". Server should send lot of event types except "ping", and they have big "data" in them, but I receive only "ping". That's strange.
I guess it could be because react-native-eventsource
misses URL query parameters, because server sends messages only if I request them in query. Could it be possible?
I don't know what additional information I can gather and would appreciate if you suggest something.
On Android I discovered pretty same issue as neilco/EventSource#16
If payload is huge, "message" event doesn't fire.
I debugged java part a little a found that payload comes cut by 4018 symbols.
Hi @JonnyBGod , I have been working sse with 'spring boot' and 'react native' and I find that the information data is not displayed, when I check the search package 'EventSource.js' that I find in funtion_registerEvents in specific' DeviceEventEmitter .addListener ('eventsourceEvent', 'you send ev.message instead of sen ev.data when i do it this change all working and can show information data, will can you do this change ?
before
var event = new EventSourceEvent(ev.type, {
data: ev.message
});
after
var event = new EventSourceEvent(ev.type, {
data: ev.data
});
thanks , for your time , good day.
On android, at least (I haven't tested iOS)
No matter what the event type, the data is sent to the onmessage
handler
For example, the following SSE stream should be delivered to a function registered with .addEventListener( 'change', fn )
but instead is delivered to the function registered with .addEventListener( 'message', fn )
...
event: change
data: {"prop":"one","value":1}
...
most issues were because the import statment it has to be import <React/RNEventSource.h> instead of import "RNEventSource.h"
I am facing a problem trying to initialize the EventSource.
componentDidMount() {
this.source = new EventSource("url_to_my_channel");
this.source.onopen = () => console.log("EventSource::Connection open");
this.source.onmessage = (message) => console.log("EventSource::onMessage", message);
this.source.onerror = (error) => console.log("EventSource::error", error);
this.source.addEventListener("custom_event", (event) => console.log("EventSource::custom_event", event))
}
I am using this implementation of Push Stream.
In EventSourceEvent.js, it mentions (correctly) that the data
property should contain the incoming data, but it has been assigned to the message
property instead (in EventSource.js).
If server sent event contains "data" property, it is ignored, but "message" used instead:
https://github.com/JonnyBGod/react-native-eventsource/blob/master/src/EventSource.js#L58
var event = new EventSourceEvent(ev.type, {
data: ev.message
});
I'm using springboot SseEmitter as a backend.
Why the closeEventListener
is not called when emitter is closed. On the contrary, ErrorEventListener
is called.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.