These are chat archives for canjs/canjs

3rd
Jun 2016
Matthew Phillips
@matthewp
Jun 03 2016 01:20
What is it you are wanting to do?
I would think you could create a demo.stache and use done-autorender with your demo page
Thomas Sieverding
@Bajix
Jun 03 2016 01:21
It loads up my main module as defined in package.json
Matthew Phillips
@matthewp
Jun 03 2016 01:22
What does your steal script tag look like?
you might want it to be <script src="path/to/steal.js" main="path/to/demo.stache!done-autorender"></script>
Thomas Sieverding
@Bajix
Jun 03 2016 01:22
<script src="../../../node_modules/steal/steal.js" main="@elated/mobile/demo.stache!done-autorender"></script>
Matthew Phillips
@matthewp
Jun 03 2016 01:23
yeah that's fine
Thomas Sieverding
@Bajix
Jun 03 2016 01:23
Yea; doesn’t work
Matthew Phillips
@matthewp
Jun 03 2016 01:23
Hm, you are saying it is loading up the main index.stache file?
That's really weird
Thomas Sieverding
@Bajix
Jun 03 2016 01:24
I’m also having troubles w/ sub templates
Super annoying =/
Matthew Phillips
@matthewp
Jun 03 2016 01:25
Think you can reduce it down? I feel like maybe something else is going on, done-autorender doesn't actually load the stache file at all, steal should be passing it your demo.stache
Thomas Sieverding
@Bajix
Jun 03 2016 01:28
/src/hello-world/hello-world.html

<script src="../../../node_modules/steal/steal.js" main="my-app/hello-world/hello-world.stache!done-autorender"></script>

/src/hello-world/hello-world.stache

<p>Hello World</p>
can done-autorender load .html files?
Thomas Sieverding
@Bajix
Jun 03 2016 01:34
Ok found a solution
I think the main thing is that subtle issues aren’t intuitive to address
<html>
  <head>
    <title>{{title}}</title>
  </head>
  <body>
    <can-import from="@elated/mobile/main"/>
    <can-import from="@elated/mobile/styles.scss!" />
    <can-import from="@elated/mobile/app" export-as="viewModel" />
    <can-import from="@elated/mobile/nav-panel/nav-panel"/>

    <p>{{message}}</p>

    <script src="../../../node_modules/steal/steal.js" main="@elated/mobile/nav-panel/demo.html!done-autorender"></script>
  </body>
</html>
That fails if I don’t have the wrapping html
I’ll post up some issues later; there are several edge cases in which things can fail in ways that aren’t obvious enough
For example, cordova builds fail if you use scoped package names, or call System.config
Super innocuous changes make things crash miserably
Julian
@pYr0x
Jun 03 2016 07:10
if you can make tests, that will help us alot
Andrei Balmus
@abalmush
Jun 03 2016 10:13

Guys is it possible to use delegate plugin same as define ? like so:

export const CartItemMap = can.Map.extend({
    define: {
        quantity: {
            type: 'number',
            set(value) {
                return value;
            }
        }
    },
    delegate: {
        quantity: {
            change(ev, value) {
                console.log(value);
            }
        }
    }
});

If no, which is the best way to bind ‘change' event to quantity attribute in this case?

Im using this map in a List:
export const CartEntriesList = can.List.extend({
    Map: CartItemMap
}, {});
Kevin Phillips
@phillipskevin
Jun 03 2016 12:07
@abalmush what do you want to do when the quantity attribute changes. is it something you can’t do in your setter for quantity?
Andrei Balmus
@abalmush
Jun 03 2016 12:34
Hi @phillipskevin, whell I want to make an ajax reques to the server an save that value, quantity binded to the dropdown element
Kevin Phillips
@phillipskevin
Jun 03 2016 12:35
is quantity used in the ajax call?
Andrei Balmus
@abalmush
Jun 03 2016 12:36
do you mean when I get quantity value on the page load?
I’m doing ajax request to the server to get all cart data, and pass it to the view like this:
can.$(this.options.container).html(
            stache(cartPageTemplate)(this.cartData)
        );
this.cartData - is a wrapper Map
it wourks if I usde delegate in my wrapper:
this.cartData.delegate('entries.*', 'change', () => {...});
I thought it possible to attache that change to the CartItemMap
Kevin Phillips
@phillipskevin
Jun 03 2016 12:40
you shouldn’t need the delegate plugin
Andrei Balmus
@abalmush
Jun 03 2016 12:41
Does setter, will be called on dropdown change?
I mean when I select new qty, I can see it in my Map
Kevin Phillips
@phillipskevin
Jun 03 2016 12:42
but your setter isn’t triggered?
Andrei Balmus
@abalmush
Jun 03 2016 12:42
yep
Am I missing something?
Kevin Phillips
@phillipskevin
Jun 03 2016 12:43
can you create a simple jsbin?
Andrei Balmus
@abalmush
Jun 03 2016 12:43
yeah sure
Kevin Phillips
@phillipskevin
Jun 03 2016 12:43
you can clone the one that is linked at the top of gitter
Andrei Balmus
@abalmush
Jun 03 2016 12:43
sure, I’ll let you know
Andrei Balmus
@abalmush
Jun 03 2016 13:02
@phillipskevin, I’ve created jsbin, and it work even with setter :) http://jsbin.com/pulexariga/1/edit?html,js,output
looks like I have some issues in my project, will try to find it, sorry my fault :(
Kevin Phillips
@phillipskevin
Jun 03 2016 13:04
no problem
let me know if I can help
Andrei Balmus
@abalmush
Jun 03 2016 13:33
thanks Kavin, I will ;)
Mason Shin
@minsooshin
Jun 03 2016 16:55
can I use es6 object literal for can.Map?
something like this
export default Map.extend({
  services: Apoc.servicesInfo,

  isServiceDown(service) {
    return service.status === 'down';
  },

  get servicesDown() {
    return _.filter(this.services, this.isServiceDown);
  }
});
Mason Shin
@minsooshin
Jun 03 2016 17:01
can anyone give me a feedback on this?
Kevin Phillips
@phillipskevin
Jun 03 2016 17:01
the only thing I’m not sure of is get servicesDown() {
Mason Shin
@minsooshin
Jun 03 2016 17:01
that’s the point I asked
getter and setter with es6 style
Kevin Phillips
@phillipskevin
Jun 03 2016 17:02
I don’t think that will work
Mason Shin
@minsooshin
Jun 03 2016 17:04
got it
you think isServiceDown() doens’t have issue, only for get serviceDown(), right?
Kevin Phillips
@phillipskevin
Jun 03 2016 17:05
if you think it should, feel free to open an issue
Mason Shin
@minsooshin
Jun 03 2016 17:06
I don’t think it should, one of our team member brought up that this morning, so I would like to ask about it.
before moving forward.
since I’ve never used es6 literal in can.Map so far.
but he thought it will be working with es6 literal.
Kevin Phillips
@phillipskevin
Jun 03 2016 17:07
it works with the other literal shorthands
like isServiceDown(service) { instead of isServiceDown: function(service) {
Mason Shin
@minsooshin
Jun 03 2016 17:07
only getter and setter has question mark
Kevin Phillips
@phillipskevin
Jun 03 2016 17:07
yeah, I don’t know what that would do
Mason Shin
@minsooshin
Jun 03 2016 17:12
isServiceDown() => declaration, and isServiceDown: function() => expression?
Kevin Phillips
@phillipskevin
Jun 03 2016 17:13
I take back what I said, this does work
var Bar = can.Map.extend({
  get foo() {
    return 'foo';
  }
});

var bar = new Bar();
console.log(bar.attr('foo')); // => ‘foo'
Mason Shin
@minsooshin
Jun 03 2016 17:14
cool
that’s great
Mason Shin
@minsooshin
Jun 03 2016 17:23
thanks @phillipskevin
Kevin Phillips
@phillipskevin
Jun 03 2016 17:23
:+1: