jimhigson / oboe.js

A streaming approach to JSON. Oboe.js speeds up web applications by providing parsed objects before the response completes.
http://jimhigson.github.io/oboe.js-website/index.html
Other
4.79k stars 208 forks source link

Oboe runs node after all the data is loaded #176

Closed dkaushik95 closed 6 years ago

dkaushik95 commented 6 years ago

I am trying to run oboe in a react-native app

oboe({url: url, headers: options.headers})
    .node('!.[*]', (data) => {
      console.log(data)
    }).start(headers => {
      console.log(headers);
      this.statusText = "Getting data..."
      // this.toggleLoading(true);
    })
    .done(response => {
      console.log("Done")
      this.incidentLoading = false;
      this.statusText = "Data loaded"
    })
    .fail(error => {
      console.log(error);
      this.statusText = "Error getting data"
      this.toggleLoading(false);
    })

What happens that the node function runs after I get all the data in. The expected behavior should be to get parts of the data in. Am I doing something wrong here?

Aigeec commented 6 years ago

Please provide an example of the data being processed. It might just be the path you are using. Try !.* rather than what you have there. There is some detail here on the various patterns: http://oboejs.com/api#pattern-matching

Hope that helps. A

dkaushik95 commented 6 years ago

My data is similar to this :

[
{fields: values},
...
]

I tried that pattern, and in the node, I am actually updating the view, but the view is updated only when the node reaches done.

Aigeec commented 6 years ago

In general when raising an issue it is best to provide a jsfiddle (or similar) of the issue in it's simplest terms.

I have take then liberty to do one for you with oboe and the data you have specified.

https://jsfiddle.net/t6akqL91/54/

This behaves as expected.

dkaushik95 commented 6 years ago

I figured out the problem, there was something wrong with mobx with Symbols. Mobx works great! Thanks @Aigeec