Skip to content
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

Done function executes for each root object instead of final object response #224

Open
rahultailwal opened this issue Nov 11, 2020 · 0 comments

Comments

@rahultailwal
Copy link

rahultailwal commented Nov 11, 2020

Hi, I have an api where we have direct root json objects like below. I have to fetch each object data from the api and push into array and also want to know when all data is completed. Basically its Newline delimited JSON streaming

{id : 1, name: 'Test1'}
{id : 2, name: 'Test1'}
{id : 3, name: 'Test1'}
{id : 4, name: 'Test1'}

I am using rsjx with oboe to do that. If i use the below then for each object I am getting done event called it should be printed at the end of 4th json object. How can we achieve this with Oboe, In the given examples there is no example for direct json object all are within some json object array or normal text. Please update

import { Observable } from 'rxjs'
import oboe from 'oboe'

const oboeService = {
streamObservable(input) {
return new Observable(obs => {
const stream = oboe(input)
stream.node('!', data => obs.next(data))
stream.done(() => console.log('donedd')) // To test when done is printed
stream.fail(e => obs.error(e))
})
},
}
export default oboeService

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

No branches or pull requests

1 participant