-4
  • I am trying to learn rx js
  • I have a fiddle with rxjs where they use api and display the values.
  • same way I am trying to load the values in my grid.
  • but I am not able to load the values.
  • is it possible to get in angular2 and will we be able to delete api values
  • can you tell me how to achieve it

working fiddle

http://jsfiddle.net/8jFJH/2534/

not working fiddle

http://jsfiddle.net/XY7HT/72/

var refreshClickStream = Rx.Observable.fromEvent(refreshButton, 'click');

var requestStream = refreshClickStream.startWith('startup click')
    .map(function() {
        var randomOffset = Math.floor(Math.random()*500);
        return 'https://api.github.com/users?since=' + randomOffset;
    });

 console.log("requestStream-------->" + JSON.stringify(requestStream));
  • Is the second jsfiddle url correct? (Seems like it is an example of kendo-ui modal windows, there are no rxjs included and no ajax calls at all) – Oles Savluk Aug 30 '17 at 08:45
  • Hey can you tell me how to achieve in second fiddle... I tried everything but not able to achieve... can you update in my fiddle now?? –  Aug 30 '17 at 10:09
  • 1
    This question is badly formulated. It just dumps code for proofreading and has no value for future site users. Explain what you tried and where you are stuck. – Gilles Lesire Aug 30 '17 at 13:09

1 Answers1

3

You can load data using built in ajax operator or by using other libraries like jQuery(used in the first JSFiddle)

So your code could look something like this (using jQuery to make AJAX call):

Rx.Observable.fromPromise($.getJSON('https://api.github.com/users'))
  .subscribe(users => {
    // do whatever you want with the users data
    ...
  })

And here is updated fiddle for you - http://jsfiddle.net/ednqfm60/1/

Oles Savluk
  • 4,315
  • 1
  • 26
  • 40