These are chat archives for canjs/canjs

19th
Dec 2016
Kevin Phillips
@phillipskevin
Dec 19 2016 20:57
Sunil George
@georgesunil81
Dec 19 2016 22:02
I have a quick question, I am making a tasks.findAll call that invokes an API with some input parameters. Some call take a longer time to respond back with data (success). How can I abort prior tasks.findAll calls and only get the data for the last call I made?
Please let me know if anyone has any ideas. Thanks.
Gira Minus
@gKreator
Dec 19 2016 22:26
Are you using jquery $.ajax?
Sunil George
@georgesunil81
Dec 19 2016 22:27
No @gKreator . I am making a CanJS model.findAll call.
Gira Minus
@gKreator
Dec 19 2016 22:27
That does not mean you are not using jquery since you can pass jquery ajax as a parameter
Just wondering
Sunil George
@georgesunil81
Dec 19 2016 22:29
I think jquery Ajax call is made under the hood when I do model.findAll()
Gira Minus
@gKreator
Dec 19 2016 22:30
blob
only if you do that
otherwise its native XHR
Sunil George
@georgesunil81
Dec 19 2016 22:32
Hmmm...here is what I am doing...
    var job = can.Model.extend({

        findAll: "GET /job/All",
Gira Minus
@gKreator
Dec 19 2016 22:32
Ohh CanJs 2.3
Sunil George
@georgesunil81
Dec 19 2016 22:33
Yup
Gira Minus
@gKreator
Dec 19 2016 22:33
Sorry I thought you were using CanJs3
Sunil George
@georgesunil81
Dec 19 2016 22:33
Not yet.
Gira Minus
@gKreator
Dec 19 2016 22:33
can you call job.obort(); ?>
abort*
Sunil George
@georgesunil81
Dec 19 2016 22:34
job also has findOne and other methods.
I will try that and see if it works though.
Gira Minus
@gKreator
Dec 19 2016 22:34
Yeah it actually might not... try it out hto
Sunil George
@georgesunil81
Dec 19 2016 22:35
Sure @gKreator . On a different note, in your code snippet, I see you are using can-connect. Are you doing some realtime stuff?
I have some requirements for handling realtime server pushes. I think I will need to use can-connect.
Gira Minus
@gKreator
Dec 19 2016 22:35
What do you mean by realtime? Like socket.io?
Sunil George
@georgesunil81
Dec 19 2016 22:35
yes
Gira Minus
@gKreator
Dec 19 2016 22:35
can-connect is just XHR
its just new api
Sunil George
@georgesunil81
Dec 19 2016 22:36
In my case, it will be SignalR on the server sending realtime pushes to clients.
Oh, okay.
Sunil George
@georgesunil81
Dec 19 2016 22:37
Thanks @gKreator for the links.
Gira Minus
@gKreator
Dec 19 2016 22:37
It is best to use socket.io for real time
yup
Sunil George
@georgesunil81
Dec 19 2016 22:38
Sure. That link you sent seems very helpful. Will go through that. Thanks a lot.
Sunil George
@georgesunil81
Dec 19 2016 22:50
job.abort() does not work, errors out with .abort() not found!
Gira Minus
@gKreator
Dec 19 2016 22:50
Yeah makes sense..
on your model for that to work
I am not exactly sure how to grab to jquery.ajax out of the model, so you might have to use an xhrpool and do it manually with jquery. http://stackoverflow.com/questions/1802936/stop-all-active-ajax-requests-in-jquery
Sunil George
@georgesunil81
Dec 19 2016 22:55
Hmmm...that link seems interesting. Will check it out. Thanks @gKreator
Justin Meyer
@justinbmeyer
Dec 19 2016 23:23
@Bajix it's in can-observation/reader
can you create an issue in canjs/canjs
Thomas Sieverding
@Bajix
Dec 19 2016 23:23
The promise stuff?
Justin Meyer
@justinbmeyer
Dec 19 2016 23:23
and we'll find a way to get it documented
yeah
@roemhildtg I just found this: https://github.com/roemhildtg/spectre-canjs ... very cool ... starred it
Thomas Sieverding
@Bajix
Dec 19 2016 23:24
IMO there should be a special mention within the stache documentation
Justin Meyer
@justinbmeyer
Dec 19 2016 23:24
yeah, probably
it can be used even in streams which is crazy ...
Thomas Sieverding
@Bajix
Dec 19 2016 23:25
I’ve been going crazy with streams
Justin Meyer
@justinbmeyer
Dec 19 2016 23:25
this.stream(".somePromise.isPending")
Thomas Sieverding
@Bajix
Dec 19 2016 23:25
It’s amazing
Yea, combine that with things like bufferWhileBy
Justin Meyer
@justinbmeyer
Dec 19 2016 23:25
yeah, the bitcentive example app is going to make use of them quite a bit
so we should have some good examples
Thomas Sieverding
@Bajix
Dec 19 2016 23:26
I feel like Kefir has been the missing link. I’ve had to rely too much on components do to things that now I can do simply with Kefir
Gregg Roemhildt
@roemhildtg
Dec 19 2016 23:26
@justinbmeyer thanks :smile: it's been a work in progress but it's definitely coming along nicely for what I'm doing at work. Hopefully others can benefit as well
Justin Meyer
@justinbmeyer
Dec 19 2016 23:27
it would be great if you can show it off at a DoneJS contributors meeting
Thomas Sieverding
@Bajix
Dec 19 2016 23:27
Sure
Justin Meyer
@justinbmeyer
Dec 19 2016 23:27
to both of you :-)
Thomas Sieverding
@Bajix
Dec 19 2016 23:27
Been meaning to follow up with you, but I’m interested in becoming an official contributor
Justin Meyer
@justinbmeyer
Dec 19 2016 23:28
awesome ... shoot me an email and I'll fill you in: justin@bitovi.com
Thomas Sieverding
@Bajix
Dec 19 2016 23:28
kk
Gregg Roemhildt
@roemhildtg
Dec 19 2016 23:32
Hm I'd be up for that possibly. I'd love to get feedback on it. Just need to finish docs and probably put a proper examples/documentation site together for it.
Thomas Sieverding
@Bajix
Dec 19 2016 23:33
function makeCount ( Map ) {
  return {
    stream: function() {
      return Kefir.combine([
        route.data.stream('.app').filter().flatMap(function( app ) {
          return Kefir.fromPromise(Map.count({
            app: app
          }));
        }),
        Stream.toStreamFromEvent(Map, 'newInstance').scan(function( n ) {
          return ++n;
        }, 0)
      ], function( count, n ) {
        return count + n;
      });
    }
  }
}
Loving me this streams bliss