These are chat archives for canjs/canjs

24th
Aug 2015
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 24 2015 00:07
Hello, how I can add additional params to my ajax request in can-connect? for example apikey for a public APi
Andrei Balmus
@abalmush
Aug 24 2015 12:09
Is there any plans to move Can.js to ES6 code?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 24 2015 12:48
@abalmush you can write canjs apps with ES6 already take a look at stealjs http://stealjs.com/
Andrei Balmus
@abalmush
Aug 24 2015 12:57
Hi @cherifGsoul, yes I tried to use it, but i had some issues with gulp-babel transpile, maybe i did some mistakes on Gulp configuration. Do you have an example of the Can.js app structure with Steal.js and ES6 modules? Maybe some “skeletone" app or something, so I can try it?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 24 2015 12:58
donejs http://donejs.com/ may help you it has generators and other stuffs
Andrei Balmus
@abalmush
Aug 24 2015 13:00
cool, let me check this, thank you a lot!
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 24 2015 13:01
welcome
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 24 2015 13:30
@justinbmeyer how to overwrite parseListData?? this dosent work for me!!
export const characterConnection = connect([
        "constructor",
        "can-map",
        "constructor-store",
        "data-callbacks",
        "data-callbacks-cache",
        "data-combine-requests",
        "data-inline-cache",
        "data-parse",
        "data-url",
        "real-time",
        "constructor-callbacks-once",
        {
            parseListData: function(rawData){

                    return rawData.data.results;
            }
        }
        ],options);
the json response is like this
{
    "data": {
        "results": [
            {
                "id":1,
                "name":"Foo"
            },
            {
                "id":2,
                "name":"Bar"
            }
        ]
    }
}
Matthew Phillips
@matthewp
Aug 24 2015 20:00
@mehiel sounds like a bug
Aggelos Karalias
@mehiel
Aug 24 2015 20:03
@matthewp I thought so.. I've fixed that locally, I could easily open an issue/PR/etc
Aggelos Karalias
@mehiel
Aug 24 2015 20:11

and another change I made today and I'd like to ask for that, is that I changed component.js:43 with:

// Define a control using the `events` prototype property.
if(this.prototype.events.prototype instanceof ComponentControl) {
  this.Control = this.prototype.events;
} else {
  this.Control = ComponentControl.extend( this.prototype.events );
}

and now I can truly extend Components like:

var ChildComp = ParentComp.extend({
  tag: 'child-comp',
  events: ParentComp.Control.extend({
    '.some-selector click': function(el, ev) {
      this._super();
      can.dev.log("Extra work from child component");
    }
  })
});
this seems really useful (at least to my use case).. Is there any other way to do it without that change? Every child component seems to replace parent's events instead of extending it..
Justin Meyer
@justinbmeyer
Aug 24 2015 20:27
@cherifGsoul I think you need to do that in a behavior
export const characterConnection = connect([
        "constructor",
        "can-map",
        "constructor-store",
        "data-callbacks",
        "data-callbacks-cache",
        "data-combine-requests",
        "data-inline-cache",
        "data-parse",
        "data-url",
        "real-time",
        "constructor-callbacks-once",
        function() { return {
            parseListData: function(rawData){

                    return rawData.data.results;
            }
        }
        }
        ],options);
try that
can you create an issue
b/c what you wrote should work
btw, you can't write parseListData: "data.results"?
dylanrtt
@dylanrtt
Aug 24 2015 20:34
@mehiel I think @alexisabril already made a PR for the list filtering bug #1755
Aggelos Karalias
@mehiel
Aug 24 2015 20:43
@dylanrtt my bad.. I should have seen that..
Aggelos Karalias
@mehiel
Aug 24 2015 20:49
regarding component extension, another way to do it which seems better (framework-wise) is to check if this.Control exists and if it is extending it. That makes it transparent to the user.. You can't override it that way though.. But if you're extending a component you probably want to do that so..
Matthew Phillips
@matthewp
Aug 24 2015 20:50
@mehiel someone tackled this previously
bitovi/canjs#1298
not sure what the status is
Aggelos Karalias
@mehiel
Aug 24 2015 20:54
and that's an old one.. cool thnx.. not sure why it's not on master/minor.. seems pretty primitive
Matthew Phillips
@matthewp
Aug 24 2015 20:57
ping justin about that, i think it was missing tests or something
David Luecke
@daffl
Aug 24 2015 20:58
Well the better ways to add functionality to custom HTML elements is either using <content> or via mixins. We realized that most of the time all you want to do is extend the viewModel. OO extensibility doesn't really fit well into the component model (you just add another layer of indirection)
You can always extend viewModels and create a new component with it. The same probably goes for the events control.
Aggelos Karalias
@mehiel
Aug 24 2015 21:08
I totally understand your point and mixins can do the work for sure.. I think viewModel extensibility is not enough on its own..
If I have a generic card (think google now) with some generic behavior attached like being draggable on a drag icon, closable on a close icon etc and then have specific card components like weather-card, traffic-card I need somehow to extend the behaviour..
If there is a problem that totally fits OO is graphics and user-interfaces..
development-wise I'd prefer extending a component than use mixins but I can live with that for sure
David Luecke
@daffl
Aug 24 2015 21:11
But that's really a behaviour not inheritance. For example what if you want a card that's closable and draggable, I would rather mix that in instead of extending from a CloseableDraggable component.
Really it could just be a custom attribute
<my-component closeable dragable></my-component>
my-component most likely doesn't have to know that it's closable or draggable at all.
Aggelos Karalias
@mehiel
Aug 24 2015 21:14
I think that real life scenarios would end up with an alienated html that way.. but I may be totally wrong..
David Luecke
@daffl
Aug 24 2015 21:17
If you can think of some example demos where you think this breaks down we can definitely discuss it.
Aggelos Karalias
@mehiel
Aug 24 2015 21:24
that would be great.. I'll try to find some time to create an example based on what I'm implementing now.. and I'd really like to discuss what implementation looks better (code-wise, maintainance-wise or any other parameter)..
Gerard Finnerty
@halcyonandon
Aug 24 2015 21:41
Hi, anyone have any suggestions for performance testing/monitoring for a canJS app... just been using yslow, but looking to get a little more granular
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 24 2015 23:56
can-connect behave is not a function?? what Im missing?