These are chat archives for canjs/canjs

10th
Aug 2016
Christopher Oliphant
@RALifeCoach
Aug 10 2016 00:46
Any comments on my issue?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 00:58
@Bajix @cherifGsoul @matthewp Any help is much appreciated.
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 00:59
@RALifeCoach use can-fixture
Christopher Oliphant
@RALifeCoach
Aug 10 2016 01:01
Is there a 3.0 version of can-fixture?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 01:01
yes
the docs show how to use it with a json file
Christopher Oliphant
@RALifeCoach
Aug 10 2016 01:11
const Players = Map.extend({
    define: {
        header: {
            Type: Object
        },
        plrs: {
            Type: Object
        }
    }
});

connect([
    require('can-connect/data/url/url'),
    require('can-connect/constructor/constructor'),
    require('can-connect/can/map/map')
], {
    Map: Players,
    url: '/players'
});

fixture("GET /players", config.playersUrl);

export default Players;
Here is what I tried, but the results are the same.
Christopher Oliphant
@RALifeCoach
Aug 10 2016 01:12
Is it expecting an ‘id’ for a get?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 01:18
I tried your suggestion and it didn’t work. I then added {id: ‘id’} in the get command. Now it is working.
That means I will have to have can-fixture into Production?
Leath Cooper
@IcculusC
Aug 10 2016 04:25
when someone is available can I get a second set of eyes on something, I think I discovered and fixed a bug in can-stache-bindings
Leath Cooper
@IcculusC
Aug 10 2016 04:38

it looks like when a function is called from a binding like

<button type="button" ($click)="clickHandler()">Click Me</button>

it doesn't differentiate a Helper expression type (from can-stache/src/expression) from a Call expression type and tries to call a function which exists on the Helper, but not the Call

Christopher Oliphant
@RALifeCoach
Aug 10 2016 13:59
This message was deleted
Christopher Oliphant
@RALifeCoach
Aug 10 2016 14:38
I am figuring out can-connect - it is working quite nicely
Christopher Oliphant
@RALifeCoach
Aug 10 2016 15:02
I have a viewModel defined as a DefineMap that I then include in a component. How do I reference/update the elements in the viewModel? In 2.3 I used this.viewModel.attr(). What do I do in 3.0?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 15:36
@cherifGsoul @matthewp @Bajix ^^
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 15:47
@RALifeCoach in 3.0 view models are attrless
this.viewModel.yourProp
Leath Cooper
@IcculusC
Aug 10 2016 15:49
@cherifGsoul could you possibly run the tests on can-stache-bindings@3.0.0-pre.5 and tell me if you see them passing?
pretty sure it's fubar
Christopher Oliphant
@RALifeCoach
Aug 10 2016 15:51
@cherifGsoul I am missing something. Do I define the viewModel as a Map or DefineMap?
I have it as a Map and this.viewmodel.myProp = ‘some value’ isn’t working
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 15:53
@RALifeCoach sorry I see your previous questions new
can-fixture yes is for testing and developing purpose to work on the frontend part withourt the API/server
Christopher Oliphant
@RALifeCoach
Aug 10 2016 15:54
I was able to replace can-fixture with getData in can-connect
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 15:54
ok
can-fixture is just to simulate ajax/api calls
Christopher Oliphant
@RALifeCoach
Aug 10 2016 15:55
But I can’t get the viewModel updated from a component event unless I define my viewModel as a Map and then use this.viewModel.attr(‘prop’, ‘some value)
When I convert from a Map to a DefineMap, I can’t update it at all
Leath Cooper
@IcculusC
Aug 10 2016 15:56
This message was deleted
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 15:56
@RALifeCoach do use to 2.x Map with define plugin?
Leath Cooper
@IcculusC
Aug 10 2016 15:57
I'm using DefineMap myself, and it works great, but I am using the this.viewModel.foo = "bar"; setters
Sunil George
@georgesunil81
Aug 10 2016 15:57
A quick question - if I add some HTML dynamically to the DOM, I wanted to have the inline stache keys to resolve to values, is that possible? For example, if I do something like -
```
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 15:58
@IcculusC if you are sure you can you open an issue?
Leath Cooper
@IcculusC
Aug 10 2016 15:58
I'm not 100% sure
Christopher Oliphant
@RALifeCoach
Aug 10 2016 15:58
I am using can-map installed via npm - that should be 3.0
Leath Cooper
@IcculusC
Aug 10 2016 15:58
I mean it seems ridiculous... it's failing 5 tests and it's completely broken
am I really the only person seeing that?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 15:58
you can use can-define also
@IcculusC Im installing dependecies
Leath Cooper
@IcculusC
Aug 10 2016 15:59
thank you
Christopher Oliphant
@RALifeCoach
Aug 10 2016 15:59
@IcculusC do you have a sample of using DefineMap as a viewModel and updating it from a compnent’s event?
Sunil George
@georgesunil81
Aug 10 2016 15:59
 $('#my-div').append('<p>{{mykey}}</p>');
Leath Cooper
@IcculusC
Aug 10 2016 15:59
I'm actually not using events at the moment
I'm fighting with event bindings instead
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:00
@cherifGsoul can you show me an example?
Sunil George
@georgesunil81
Aug 10 2016 16:00
Is there a way that the above stache key be resolved into its value also when it is dynamically inserted into the DOM?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 16:01
@RALifeCoach I dont have working example but you can check the tests
@georgesunil81 $('#my-div').append(can.view('<p>{{mykey}}</p>',{myKey: value}));
Sunil George
@georgesunil81
Aug 10 2016 16:02
Thanks @cherifGsoul I will try it out. Thanks for the help.
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 16:02
np
@IcculusC did you check the binding docs?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:04
‘check the tests’ that sounds like a very time consuming activity
Leath Cooper
@IcculusC
Aug 10 2016 16:05
@cherifGsoul yeah, I opened an issue on can-component when I thought it was an error there if you want to see how I'm using it it's issue #27
err, on that repo not his one
canjs/can-component#27
@RALifeCoach just gotta install dependencies and type npm test lol
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:07
I am looking for a very specific piece of code to discover the magic syntax to make this work. That won’t happen by typing npm test.
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 16:09
@RALifeCoach I hope you are just experiementing with 3.0!!
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:11
Experimenting or not I still need to find the magic syntax.
(As a comment that how working with CanJS feels. You fight with it until you find the magic syntax and then it starts working.)
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 16:13
@RALifeCoach How you write your component?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:14
Component.extend({
    tag: 'pgat-player-bio',
    template,
    viewModel: PlayerBioViewModel,
    events: {
        inserted: function () {
            Players.get({ id: 'id' }).then($.proxy((data)=>{
                this.onPlayersData(data);
            }, this));
            console.log(this.viewModel.personalStats.scoringAverage;
        },
        onPlayersData: function (playerList) {
            this.players = {};
            playerList.players.forEach((player)=>{
                this.players[player.playerId] = player;
            });
            this.viewModel.attr('playerList', playerList);
        }
    }
});
The viewModel is:
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 16:14
PlayerBioViewModel is with the new can-define?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:15
var PlayerBioViewModel = DefineMap.extend({
    name: 'Select Player',
    personalInfo: {
        Value: PlayerBio
    },
    personalResults: {
        Value: PlayerResults
    },
    personalStats: {
        Value: PlayerStats
    },
    personalStat186: {
        Value: PlayerStat186
    },
    playerList: {
        players: []
    },
    showMetric: false
});
Two issue, so far, the values are not being initialized and I can’t update the values from the component events
I have tried this.viewModel.attr(‘property…), this.viewModel.set(‘property’…), this.viewModel.property
For item 1 PlayerStat186 is:
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:20
var PlayerStat186 = DefineMap.extend({
    owgRank: {
        value: ''
    }
});
But in the inserted event playerStat186 is undefined
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 16:23
@RALifeCoach what are the dependencies for the viewModel
?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:24
do you mean this? var DefineMap = require('can-define/map/map');
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 16:24
yes what else?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:26
What are you looking for?
I don’t think there is anything else.
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 16:29
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:30
do I assign it to anything or just require it?
I added can-view-model. this.viewModel.playerStats is still undefined. When I assign this.viewModel.playerList = playerList; I do not get an error, but nor do I see the data in the stache.
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 16:35
I can not realy help you right now
I need time to try it
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:35
I understand. You have a job that requires your attention.
Mohamed Cherif Bouchelaghem
@cherifGsoul
Aug 10 2016 16:36
:)
I learn the 3.0 like you :)
Leath Cooper
@IcculusC
Aug 10 2016 16:36
hey @RALifeCoach is your code on github somewhere
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:36
Who actually knows it?
No it isn’t on github. It is on my corporate repo.
Leath Cooper
@IcculusC
Aug 10 2016 16:37
I've got a decent handle on how it works, but I'm stuck on a big fat glaring error in the event bindings lol
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:37
If you want I can extract the relavent pieces and add them to github
Leath Cooper
@IcculusC
Aug 10 2016 16:38
I don't know if I can really help just yet, I think you're using it in a different way than I am
I was just going to take a look if it was
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:38
It sounds like I am.
Leath Cooper
@IcculusC
Aug 10 2016 16:38
let me scroll up one sec
oh yeah
you're using events I'm using binding in the template
but are you sure the the Value: something syntax is correct
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:40
At this stage, I’m not sure of anything
Leath Cooper
@IcculusC
Aug 10 2016 16:40
in mine I'm using
thing: {
  value: object,
  Type: SomeClass
}
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:40

here is the excerpt from the docs
Value {function}: Specifies a function that will be called with new whose result is set as the initial value of the attribute.

// A default empty DefineList of hobbies:
var Person = DefineMap.extend({
hobbies: {Value: DefineList}
});

new Person().hobbies //-> []

Leath Cooper
@IcculusC
Aug 10 2016 16:40
which initializes a new instance of that class as the value of that field
weird
one sec
let LoginViewModel = DefineMap.extend({
    user: {
        value: Object,
        Type: User
    }
});

Component.extend({
    tag: "login-form",
    template: Login,
    ViewModel: LoginViewModel
});
here's an example of some code that works and properly populates the field on the view model
where the template is stored in a separate stache
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:43
That’s similar to what I have
Leath Cooper
@IcculusC
Aug 10 2016 16:44
however I'm not using the events object in the viewmodel obviously
instead when I create a function on the view model I use the ($event) syntax
but that seems to be extremely broken
            <button type="button" class="btn btn-warning btn-large btn-block" ($event)="clicked()">Login</button>
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:45
My approach is probably also broken
Leath Cooper
@IcculusC
Aug 10 2016 16:45
are you using a DefineMap
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:45
They both probably use the same underlying, broken, code
I have tried Map and DefineMap
I have more luck with Map
Leath Cooper
@IcculusC
Aug 10 2016 16:46
have you tried logging out the value of this.viewModel
and just looking at the structure of it
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:46
I’ll do that now
Leath Cooper
@IcculusC
Aug 10 2016 16:46
that's how I traced my bug back to can-stache-bindings
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:47
It is still uninstantiated
Leath Cooper
@IcculusC
Aug 10 2016 16:47
try logging "this"
can you link your component code one more time too I can't find it
this laptop is crap
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:48
here is the whole thing:
import Component from 'can-component';
var DefineMap = require('can-define/map/map');
var Map = require('can-map');
import $ from 'jquery';
import stache from 'can-stache';
import template from './player-bio.stache!';
import Players from '../models/players-model';
import PlayerBio from '../models/player-bio-model';
import PlayerResults from '../models/player-results-model';
import PlayerStats from '../models/player-stats-model';
import PlayerStat186 from '../models/player-stat186-model';
require('bootstrap/dist/css/bootstrap.css');
require('./player-bio.less');
require('./player-bio-ad');
require('can-view-model');

var PlayerBioViewModel = DefineMap.extend({
    name: 'Select Player',
    personalInfo: {
        value: Object,
        Type: PlayerBio
    },
    personalResults: {
        value: Object,
        Type: PlayerResults
    },
    personalStats: {
        value: Object,
        Type: PlayerStats
    },
    personalStat186: {
        value: Object,
        Type: PlayerStat186
    },
    playerList: {
        players: []
    },
    showMetric: false
});

Component.extend({
    tag: 'pgat-player-bio',
    template,
    viewModel: PlayerBioViewModel,
    events: {
        inserted: function () {
            Players.get({ id: 'id' }).then($.proxy((data)=>{
                this.onPlayersData(data);
            }, this));
            console.log(this);
        },
        '.switcher click': function () {
            this.viewModel.attr('showMetric', !this.viewModel.attr('showMetric'));
        },
        '.dropdown-icon click': function () {
            $('.dropdown').removeClass('hidden');
            $('.dropdown-content').removeClass('hidden');
        },
        '.player-select click': function (element) {
            $('.dropdown').addClass('hidden');
            $('.dropdown-content').addClass('hidden');
            var playerId = $(element).attr('data-id');
            PlayerBio.get({ id: playerId }).then($.proxy((data)=>{
                this.onPlayerBioData(data);
            }, this));
            PlayerResults.get({
                id: playerId,
                year: '2016'
            }).then($.proxy((data)=>{
                this.onPlayerResultsData(data);
            }, this));
            PlayerStats.get({
                id: playerId,
                year: '2016'
            }).then($.proxy((data)=>{
                this.onPlayerStatsData(data);
            }, this));
            PlayerStat186.get({
                id: playerId
            }).then($.proxy((data)=>{
                this.onPlayerStat186Data(data);
            }, this));
        },

        onPlayerBioData: function (playerBio) {
            playerBio.countryCode = this.players[playerBio.playerId].countryCode;
            this.viewModel.attr('name', playerBio.name);
            this.viewModel.attr('personalInfo', playerBio);
        },

        onPlayerResultsData: function (playerResults) {
            this.viewModel.attr('personalResults', playerResults);
        },

        onPlayersData: function (playerList) {
            this.players = {};
            playerList.players.forEach((player)=>{
                this.players[player.playerId] = player;
            });
            this.viewModel.playerList = playerList;
        },

        onPlayerStat186Data: function (playerStat186) {
            this.viewModel.attr('personalStat186', playerStat186);
        },

        onPlayerStatsData: function (playerStats) {
            this.viewModel.attr('personalStats', playerStats);
        }
    }
});

$(document.body).append(stache('<pgat-player-bio></pgat-player-bio>'));
Leath Cooper
@IcculusC
Aug 10 2016 16:49
capitalize the v in viewModel on your component definition
like where it says viewModel: PlayerViewModel or whatever
this laptop has a cell phone processor hard to scroll up lol
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:50
now can-map is blowing up with computedAttr.compute is not a function
Leath Cooper
@IcculusC
Aug 10 2016 16:50
is it a define map or a map
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:51
DefineMap
Leath Cooper
@IcculusC
Aug 10 2016 16:51
oh
because .attr no longer exists
so basically when you use DefineMap you need to pass it into the ViewModel field not the viewModel field on the component definition
no idea why
and when I wa susing map I had to create an instance of the view model manually
like
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:52
I am using DefineMap and I am passing it to ViewModel. And experiencing a whole new exception being thrown
Leath Cooper
@IcculusC
Aug 10 2016 16:53
viewModel: new ViewModelMap()
because you're using attr
attr doesn't exist with DefineMa
p
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:54
Most of the references to attr are not being used. The key line is this.viewModel.playerList = playerList
Leath Cooper
@IcculusC
Aug 10 2016 16:54
does the view model exist when you use ViewModel rather than viewModel
if you log it out
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:55
It crashes loading the component - so I can’t tell
Leath Cooper
@IcculusC
Aug 10 2016 16:55
:(
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:56
I will instantiate it outside the component and see what I get
Leath Cooper
@IcculusC
Aug 10 2016 16:56
wish I could help more but I'm not knee deep in the code like you haha
Christopher Oliphant
@RALifeCoach
Aug 10 2016 16:56
okay - you have helped some
thanks for your time
Leath Cooper
@IcculusC
Aug 10 2016 16:57
any time
I'm here trying to learn 3.0 too
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:03
It’s working!!
Leath Cooper
@IcculusC
Aug 10 2016 17:05
lol what did you do
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:14
I found an error in one of my sub-maps
Leath Cooper
@IcculusC
Aug 10 2016 17:14
ah
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:14
that and changing viewModel to ViewModel seems to have done the trick
Leath Cooper
@IcculusC
Aug 10 2016 17:14
yeah that viewModel and ViewModel thing is confusing, there's an issue open to add a warning if you use the wrong one so hopefully that will get implemented
Leath Cooper
@IcculusC
Aug 10 2016 17:24
can you try something for me
seeing the same error in two environments
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:25
sure, how can I help?
Leath Cooper
@IcculusC
Aug 10 2016 17:25
hmm
one sec
nevermind not sure how to do this efficiently lol
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:26
okay
Leath Cooper
@IcculusC
Aug 10 2016 17:27
I'm like 100% sure that this binding syntax is completely broken but nobody else seems to notice lol
so I just built a test project in a completely fresh environment and got the same issue
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:28
I have found that sometimes they are too busy to listen and at other times I get an amazing amount of help
Leath Cooper
@IcculusC
Aug 10 2016 17:29
not their fault
but usingthe syntax you're using for events nothing ever gets called, and using the syntax from can-stache-bindings docs it just breaks
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:30
my events get called
Leath Cooper
@IcculusC
Aug 10 2016 17:31
oh I'm dumb
so the events part probably works, but the stache binding to viewmodel functions definiteyl doesn't
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:32
I haven’t tried binding stache to helpers in 3.0
Leath Cooper
@IcculusC
Aug 10 2016 17:32
not helpers, helpers are a different thing
just defining a function on the viewmodel and then binding it with ($click)="functionCall()"
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:33
viewModel functions?
right
switch your code over to my style and maybe all will work….
Leath Cooper
@IcculusC
Aug 10 2016 17:33
it works your way
but it should work both ways
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:34
Have you used DefineList?
Leath Cooper
@IcculusC
Aug 10 2016 17:35
nah not yet
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:36
It seems to work. Because 3.0 is suspect and because CanJS is so picky, I forget to look in my code for errors.
Leath Cooper
@IcculusC
Aug 10 2016 17:38
well it just frustrates me because I like to write code a specific way and the type of style I normally use is supported according to the docs but doesn't work in the stache parser
Leath Cooper
@IcculusC
Aug 10 2016 17:43
oh well I'll just define my events on the component
that's a pretty nifty way to do it anyway
Christopher Oliphant
@RALifeCoach
Aug 10 2016 17:49
I like it because it keeps all the information about events in the same place
otherwise part is in stache and part in the viewModel
Leath Cooper
@IcculusC
Aug 10 2016 18:09
yeah but in my mind the purpose of the viewmodel is a container for all of the functions(and other goodies) to support the view(the stache) so why would I define the functions outside of the viewmodel
Christopher Oliphant
@RALifeCoach
Aug 10 2016 18:10
What is the syntax for a simple click event?
Mason Shin
@minsooshin
Aug 10 2016 18:11
anyone know how to guarantee component A’s removed event called first then component B’s inserted event called?
what I am trying to do is when component A is removed hide a global dom element, and when component B is inserted show it again.
I have a Class for the handling global dom, but hide method called later than show method of the class.
Christopher Oliphant
@RALifeCoach
Aug 10 2016 18:16
@IcculusC I tried ($click)=“huh()” and I get expr.hash is not a function
Leath Cooper
@IcculusC
Aug 10 2016 18:18
yep
going to draft up an issue soon
back in a bit
Christopher Oliphant
@RALifeCoach
Aug 10 2016 18:19
That should be simple - point to the demo on their docs page. It has the same result.
Mason Shin
@minsooshin
Aug 10 2016 18:24
if I route from A to B, component A’s removed event called later than component B’s inserted event. Is there a way to make sure previous page’s component removed event called first?
Leath Cooper
@IcculusC
Aug 10 2016 18:53
lol @RALifeCoach guess waht
I went to start writing a detailed explanation of the issue and I go to the repo
and it's been fixed, just not released
Christopher Oliphant
@RALifeCoach
Aug 10 2016 18:54
When is the release scheduled?
Leath Cooper
@IcculusC
Aug 10 2016 18:55
haven't looked lol but it was fixed 7 hours ago
Matthew Phillips
@matthewp
Aug 10 2016 20:13
@RALifeCoach yes, you define it as a definemap
no more regular Maps
var ViewModel = DefineMap.extend({
  prop: "string"
});

var vm = new ViewModel();
vm.prop = 'foo';
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:13
Thanks @matthewp I was finally able to get it all working.
Matthew Phillips
@matthewp
Aug 10 2016 20:14
there's some examples in the major branch you might want to look at
kind of show how DefineMaps are used as vms
Leath Cooper
@IcculusC
Aug 10 2016 20:15
will be nice if there's a warning for viewModel vs ViewModel too
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:15
It turned out I had an error in one of my sub-maps. I discovered that by defining the map outside of the component.
Matthew Phillips
@matthewp
Aug 10 2016 20:15
viewModel still exists, what would the warning be?
Leath Cooper
@IcculusC
Aug 10 2016 20:15
well if you use a DefineMap it doesn't act as expected
Matthew Phillips
@matthewp
Aug 10 2016 20:15
right
i forgot why exactly that was
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:16
Also I had to use ViewModel in my component, not viewModel
Leath Cooper
@IcculusC
Aug 10 2016 20:16
so maybe the distinction between an instance of Map vs DefineMap and vM vs V
M
Matthew Phillips
@matthewp
Aug 10 2016 20:16
maybe we should just warn against using viewModel at all
Leath Cooper
@IcculusC
Aug 10 2016 20:16
and a warning if you're using them wrong
also @matthewp good to see those new releases I banged my head against the wall over that expr.hash issue for 3 days before I decided to track it down... then you fix it on the same day lol
Matthew Phillips
@matthewp
Aug 10 2016 20:17
ah, sorry
that stuff was broken for a little while
Leath Cooper
@IcculusC
Aug 10 2016 20:17
was typing up a detailed issue for you and I went to check the line number and you'd fixed it
Matthew Phillips
@matthewp
Aug 10 2016 20:17
I think you're right about viewModel vs ViewModel but I'm not sure what the solution is
can you post an issue in can-component?
Leath Cooper
@IcculusC
Aug 10 2016 20:18
nah I was more amused than anything
yeah I'll recreate it and get some details
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:18
Leath and I worked it out
Leath Cooper
@IcculusC
Aug 10 2016 20:18
I think if you instantiate an instance of your DefineMap with viewModel it works
but if you just pass the constructor you extended it doesn't
Matthew Phillips
@matthewp
Aug 10 2016 20:18
the problem is that can-component doesn't depend on DefineMap so it wouldn't have a way to detect that viewModel is a DefineMap
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:19
But I do have questions regarding getting production ready when using StealJS.
Leath Cooper
@IcculusC
Aug 10 2016 20:19
yeah I suppose there's no really good way to do that
without including them so you can do instanceof
and bloat dependencies
Matthew Phillips
@matthewp
Aug 10 2016 20:19
yeah
Justin Meyer
@justinbmeyer
Aug 10 2016 20:19

@IcculusC

and when I wa susing map I had to create an instance of the view model manually

what do you mean by that?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:19
I don’t want my production page retrieving 80 small files. Can CanJS and all my JS files be merged for production?
Justin Meyer
@justinbmeyer
Aug 10 2016 20:20
generally speaking, one should not be using a single instance for every component
@matthewp that might not be entirely true anymore
we can probably take a good stab at it
Matthew Phillips
@matthewp
Aug 10 2016 20:20
Justin Meyer
@justinbmeyer
Aug 10 2016 20:20
with types.isConstructor
Leath Cooper
@IcculusC
Aug 10 2016 20:21
let MyViewModel =DefineMap.extend({...});

Component.extend({
  tag: 'foo-tag',
  template: '<h3>bar</h3>',
  viewModel: new MyViewModel()
});
vs
  ViewModel: MyViewModel
bump so I can edit
Justin Meyer
@justinbmeyer
Aug 10 2016 20:21
yeah, viewModel: new MyViewModel() is going to use only one instance for every foo-tag
Leath Cooper
@IcculusC
Aug 10 2016 20:22
yeah, that's what I figured
Matthew Phillips
@matthewp
Aug 10 2016 20:22
we can figure out some way to warn, i think it's a good thing to do
Leath Cooper
@IcculusC
Aug 10 2016 20:22
which worked in the use case
Justin Meyer
@justinbmeyer
Aug 10 2016 20:22
yeah, but if you have multiple foo-tag on the page
it's going to get weird
Leath Cooper
@IcculusC
Aug 10 2016 20:22
yeah I figured, but it was just a single form with a single instnace of the view model per visit
I thought that may be the case
but never ran into the multiple instances of foo-tag yet
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:23
Also if I do var map = new MyDefineMap() and there is an error in one of the sub-maps I can view map and see which one has an error. If I define MtDefineMap in the Component with ViewModel, then there is a nondescript error.
Leath Cooper
@IcculusC
Aug 10 2016 20:23
would it be a reasonable solution to just put something on the define map like a boolean value that differentiates it from a normal map and check for it if it's passed into viewModel and warn from there?
then the object would have the value if it were a define map but wouldn't require component to include define map as a dependency
Justin Meyer
@justinbmeyer
Aug 10 2016 20:25
@halcyonandon I saw your comments about vdom and such, but I'm not sure I understand them. A virtual DOM is any structure that isn't the actual dom, but can effectively represent the actual DOM. In the case of can-simple-dom, our DOM looks pretty similar to the actual DOM apis, but it's much faster. The similarity allows us to have things like jQuery mutate our virtual DOM.
Leath Cooper
@IcculusC
Aug 10 2016 20:25
kind of a ghetto workaround but it keeps the bloat down and accomplishes something similar to using instanceof
Justin Meyer
@justinbmeyer
Aug 10 2016 20:26
define map like a boolean value that differentiates it from a normal map and check for it if it's passed into viewModel and warn from there?
not really a good long term solution b/c we want people to use can-define to be able to add observability to constructors created with class expressions
types.isConstructor basically checks if a function has a modified .prototype
which, IMO, is a pretty close approximation to when to use new in almost any circumstance
and would cover all uses of DefineMap
Leath Cooper
@IcculusC
Aug 10 2016 20:28
will Map be deprecated?
could do it the other way around
put he check on the Map not the DefineMap
Justin Meyer
@justinbmeyer
Aug 10 2016 20:29
our place for this kinda type detection behavior is in : http://canjs.github.io/canjs/doc/can-util/js/types/types.html
Leath Cooper
@IcculusC
Aug 10 2016 20:29
unless I'm misunderstanding
Justin Meyer
@justinbmeyer
Aug 10 2016 20:30
well, viewModel is mostly being deprecated. That's what I'm focused on.
in an ideal world, we'd have 2 functions ...
well, 2 properties
ViewModel -> assumes you pass it a constructor function.
Leath Cooper
@IcculusC
Aug 10 2016 20:31
yep
Justin Meyer
@justinbmeyer
Aug 10 2016 20:31
scope -> you can do whatever the heck you want here ... function called with outer scope, element, etc, returns a new scope or anything else gets put in a new Scope.
viewModel is basically legacy
Leath Cooper
@IcculusC
Aug 10 2016 20:32
well if that's the case why not just warn people if they use viewModel at all
and encourage them to use the new convention
Justin Meyer
@justinbmeyer
Aug 10 2016 20:32
yeah, not a bad idea
Leath Cooper
@IcculusC
Aug 10 2016 20:32
maybe one of those fancy "soon to be deprecated" warnings
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:33
steal-tools - what if my main module isn’t main.js
Thomas Sieverding
@Bajix
Aug 10 2016 20:33
Then define it in your package.json
Leath Cooper
@IcculusC
Aug 10 2016 20:33
change it in your package.json
lol
Justin Meyer
@justinbmeyer
Aug 10 2016 20:34
@halcyonandon regarding checkbox docs ... @matthewp is adding two-way converters right now
Leath Cooper
@IcculusC
Aug 10 2016 20:34
"main": "index.js",
for example from mine
Justin Meyer
@justinbmeyer
Aug 10 2016 20:34
Thomas Sieverding
@Bajix
Aug 10 2016 20:34
@justinbmeyer Does can-connect have any synchronous lookup methods suitable for parseInstanceData?
Justin Meyer
@justinbmeyer
Aug 10 2016 20:35
lookup of what?
things in the store?
Thomas Sieverding
@Bajix
Aug 10 2016 20:35
Yea
Justin Meyer
@justinbmeyer
Aug 10 2016 20:35
.instanceStore.get( id )
or you can use
Thomas Sieverding
@Bajix
Aug 10 2016 20:35
I thought that returned a promise?
Justin Meyer
@justinbmeyer
Aug 10 2016 20:36
.hydrateInstance( ... )
nope
Thomas Sieverding
@Bajix
Aug 10 2016 20:37
Is there any way to do a findAll against local only? I was thinking of doing some aggregate-based side-loading
Justin Meyer
@justinbmeyer
Aug 10 2016 20:37
cache-requests already does this
not sync though
but I did make some private sync methods in memory-cache
@halcyonandon we're adding some default converters like boolean-to-inList ... which should include examples w/ checkboxes
we aren't sure about what the helpers should look like ... maybe once @matthewp has this ready, please check it out and let us know what you think
Thomas Sieverding
@Bajix
Aug 10 2016 20:38
Sure, but I’d like to use superMap, but in some use cases have lists that pull data from cache, so that I could side-load data using aggregates
There are other places in which I would use findAll normally
Justin Meyer
@justinbmeyer
Aug 10 2016 20:39
not totally sure what you mean ...
Thomas Sieverding
@Bajix
Aug 10 2016 20:40
I’ll give you a use-case
Justin Meyer
@justinbmeyer
Aug 10 2016 20:40
1st ... on using superMap ... well ... yeah it's nice b/c it's small .. but it's ok to create custom connections.
it's harder, but the flexibility is there on purpose.
(this is why i want to add a can-mixin post 3.0 so it's a bit easier to assemble them on your own)
ok ... use cases that pull from cache ...
?
Thomas Sieverding
@Bajix
Aug 10 2016 20:41
I want to be able to query all connections, then separately query all connections for a given user
And then have a websocket API that pushes out connection data
Justin Meyer
@justinbmeyer
Aug 10 2016 20:41
ok, lets break that down a bit ... connections === a can-connect connection?
query a connection ... connection.getList?
Thomas Sieverding
@Bajix
Aug 10 2016 20:42
Oh it’s a superMap
Justin Meyer
@justinbmeyer
Aug 10 2016 20:42
query all connections ... not sure what you mean ... all at the same time?
Thomas Sieverding
@Bajix
Aug 10 2016 20:42
from a can.map.extend
Justin Meyer
@justinbmeyer
Aug 10 2016 20:42
a superMap returns a connection
but it wires up the map to call into that connection
Thomas Sieverding
@Bajix
Aug 10 2016 20:43
Ok so my connection model tracks websocket connections
Justin Meyer
@justinbmeyer
Aug 10 2016 20:43
basically ... when I say "connection" I'm talking about the internal mix of behaviors that superMap creates and it's Map type's .getList is calling
Thomas Sieverding
@Bajix
Aug 10 2016 20:43
and I want to be able to publish information from that using a websocket API
Justin Meyer
@justinbmeyer
Aug 10 2016 20:43
ah, so you have a connection for connection types :-)
Thomas Sieverding
@Bajix
Aug 10 2016 20:44
and query all known instances from local
Justin Meyer
@justinbmeyer
Aug 10 2016 20:44
like your Map name is Connection?
Leath Cooper
@IcculusC
Aug 10 2016 20:44
lol
Thomas Sieverding
@Bajix
Aug 10 2016 20:44
Yes
Justin Meyer
@justinbmeyer
Aug 10 2016 20:44
haha
Leath Cooper
@IcculusC
Aug 10 2016 20:44
is this a bit
Justin Meyer
@justinbmeyer
Aug 10 2016 20:44
ok, let me reread what you wrote with that understanding
Thomas Sieverding
@Bajix
Aug 10 2016 20:44
It’s quite literally a document to represent the Websocket connection info
Justin Meyer
@justinbmeyer
Aug 10 2016 20:45
(or if you could translate this into Todo or some other type ... that might be helpful)
I want to be able to query all todos, then separately query all todos for a given user
And then have a websocket API that pushes out todos data
does that still ring true?
Thomas Sieverding
@Bajix
Aug 10 2016 20:46
Essentially I want can.List’s that don’t hit the API, but will pick up any instances matching it’s set logic
And I want to do so without removing any superMap behavior
Then I’d load in data indirectly
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:49
I tried using superMap within my stache. I gave up, even with a lot of help from Thomas.
Thomas Sieverding
@Bajix
Aug 10 2016 20:49
;o
Leath Cooper
@IcculusC
Aug 10 2016 20:50
well now I know who to go to once I get my feathers side built out!
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:50
Now I use can-connect and execute a get in the component inserted event
Thomas Sieverding
@Bajix
Aug 10 2016 20:51
I’ve got a use case in which I could side-load data using the MongoDB aggregate pipeline in order to take advantage of the $group stage.
Justin Meyer
@justinbmeyer
Aug 10 2016 20:51
@RALifeCoach use a define value in your view models
@Bajix so you want the fall-through cache initially, but after that cache-requests?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:52
@justinbmeyer I would love to see a working non-docs example. My get was a json file, not a rest api.
Justin Meyer
@justinbmeyer
Aug 10 2016 20:52
non-docs?
Thomas Sieverding
@Bajix
Aug 10 2016 20:52
@justinbmeyer Yes, and I want to do so without removing any behavior
Justin Meyer
@justinbmeyer
Aug 10 2016 20:52
what do you mean by "removing any behavior"?
what behavior are you thinking would be removed?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:52
Your toDo example from the docs I’m sure works. But the world is more complex than that.
Justin Meyer
@justinbmeyer
Aug 10 2016 20:53
more complex app
Thomas Sieverding
@Bajix
Aug 10 2016 20:53
I mean that I want to use every behavior associated with superMap
Justin Meyer
@justinbmeyer
Aug 10 2016 20:53
yeah, that's fine
so the problem is really keeping localStorage
it's really easy to drop that and bring in cache-requests
and everything would work
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:54
And even in the ToDo example you gloss over the API portion. I want an example where the rest api already exists and doesn’t conform to standards
Leath Cooper
@IcculusC
Aug 10 2016 20:54
lol is bitballs a real thing you made @justinbmeyer
Thomas Sieverding
@Bajix
Aug 10 2016 20:54
@justinbmeyer What issue is there here with localStorage?
Justin Meyer
@justinbmeyer
Aug 10 2016 20:54
sorry, not localStorage
the problem is with the fall-through-cache
@IcculusC yeah?
@Bajix you could swap the fall-through-cache strategy with cache-requests
and you'd pretty much have what you want
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:55
@justinbmeyer the bitballs example assumes standard API calls. I don’t have control over the API end and that is true for most developers working on legacy systems.
Justin Meyer
@justinbmeyer
Aug 10 2016 20:55
sure, but that has nothing to do with using "inserted" to load data
Thomas Sieverding
@Bajix
Aug 10 2016 20:55
Ok
Leath Cooper
@IcculusC
Aug 10 2016 20:55
just curious, I looked at you guys for a job a while back and saw that you are CEO and "basketballer"
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:56
I would love to use stache loading, but I spent 4 days beating my head against that wall before conceeding defeat
Justin Meyer
@justinbmeyer
Aug 10 2016 20:56
I'm not sure what stache loading is
@Bajix cache-requests always will hit what's in the store
so if you loaded all data ... then loaded a subset ... it will never go back to the server
it's really good for real-time
Thomas Sieverding
@Bajix
Aug 10 2016 20:57
@justinbmeyer What would prevent it from automatically using data-url?
Justin Meyer
@justinbmeyer
Aug 10 2016 20:58
it uses data-url if it doesn't have the data already
say you wrote
Todo.getList({})
it would hit GET /todos
then you wrote
Todo.getList({userId: 5})
Christopher Oliphant
@RALifeCoach
Aug 10 2016 20:58
Referencing the superMap tag in the stache file, showing “Is Loading” while isPending is true, and then displaying the the stache for the component, once the data is loaded.
Justin Meyer
@justinbmeyer
Aug 10 2016 20:58
it would use the todos returned by {}
Thomas Sieverding
@Bajix
Aug 10 2016 20:58
For my use case, I want to explicitely disable data-url
Justin Meyer
@justinbmeyer
Aug 10 2016 20:59
not for the first load though right?
Thomas Sieverding
@Bajix
Aug 10 2016 20:59
As the data will be loaded after the fact
I’m delaying loading findAll until a websocket connection is established
Justin Meyer
@justinbmeyer
Aug 10 2016 20:59
@RALifeCoach ok ... but that's different than what I'm talking about
Thomas Sieverding
@Bajix
Aug 10 2016 21:00
Then I’m loading based off of time, and letting my websocket connection publish going forward
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:00
Sorry, there are several different conversations going on at once
Justin Meyer
@justinbmeyer
Aug 10 2016 21:00
@Bajix what do you mean by "based off time"?
sounds like you need a data-websocket behavior.
Thomas Sieverding
@Bajix
Aug 10 2016 21:02
I have a creation time on my data, and I would want to query things created before connecting, but after the crreation time of the last thing cached
Justin Meyer
@justinbmeyer
Aug 10 2016 21:02
ah ... last thing cached in localstorage?
Thomas Sieverding
@Bajix
Aug 10 2016 21:03
Yes
Justin Meyer
@justinbmeyer
Aug 10 2016 21:03
this is a perfect opportunity for a behavior
Thomas Sieverding
@Bajix
Aug 10 2016 21:03
Oh?
Justin Meyer
@justinbmeyer
Aug 10 2016 21:03
like .. this is exactly the scenario can-connect was built to handle
Thomas Sieverding
@Bajix
Aug 10 2016 21:03
I know ;p
Justin Meyer
@justinbmeyer
Aug 10 2016 21:03
well built to be ABLE to handle
doesn't handle it
Thomas Sieverding
@Bajix
Aug 10 2016 21:04
Though I don’t see why data-websocket would be a behavior
Justin Meyer
@justinbmeyer
Aug 10 2016 21:05
you query the websocket once it's connected for the new things right?
Thomas Sieverding
@Bajix
Aug 10 2016 21:05
Nope
Though I suppose I could do it that way
Justin Meyer
@justinbmeyer
Aug 10 2016 21:05
when / how do you query the new things?
Thomas Sieverding
@Bajix
Aug 10 2016 21:06
I would query things using findAll after my websocket connection is online
Justin Meyer
@justinbmeyer
Aug 10 2016 21:06
oh ... I would fire getList and forget
Thomas Sieverding
@Bajix
Aug 10 2016 21:06
Then I’d use something like hydrateInstance to handling incoming data from my websocket connection
Justin Meyer
@justinbmeyer
Aug 10 2016 21:06
ok, so I'm not sure how all this works ... but let me take a stab at some sudo code
Thomas Sieverding
@Bajix
Aug 10 2016 21:06
Sure
onData: function( packet ) {
  var action = packet[0],
    data = packet[2];

  switch (action) {
    case 'DELETE channel':
      return Channel.model(data).destroyed();
    case 'DELETE message':
      return Message.model(data).destroyed();
    case 'DELETE user':
      return User.model(data).destroyed();
    case 'channel':
      return this.dispatch('channel', [Channel.model(data)]);
    case 'message':
      return this.dispatch('message', [Message.model(data)]);
    case 'user':
      return this.dispatch('user', [User.model(data)]);
  }
},
This is an example of a similar use-case to what I’m building now
      '{scope} onlineAt': function( scope, ev, onlineAt ) {
        var channel = scope.attr('channel');

        if (onlineAt) {
          Message.findAll({
            channel: channel._id,
            limit: channel.config.loadMessageCount
          });

          User.findAll({
            channel: channel._id,
            limit: config.chat.loadMessageCount
          });
        }
      },
So onlineAt would be the time my connection goes online
This was pre can-connect
My models were setup to emit newInstance on prototype.init on their constructor
I was combining the two data sets manually
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:11
back to steal-tools - I have in my package.son
  "system": {
    "main": "modules/page.players-redesign/player-bio/components/player-bio.js"
  },
/git/pgatour-cq-v2/front-end/node_modules/steal-tools/lib/graph/make_graph_with_bundles.js:83
    if( Array.isArray(cfg.main) ) {
                         ^

TypeError: Cannot read property 'main' of undefined
    at module.exports (/git/pgatour-cq-v2/front-end/node_modules/steal-tools/lib/graph/make_graph_with_bundles.js:83:23)
Leath Cooper
@IcculusC
Aug 10 2016 21:11
not in system
it's a top level package.json field
Thomas Sieverding
@Bajix
Aug 10 2016 21:12
@IcculusC It’s in both
Leath Cooper
@IcculusC
Aug 10 2016 21:12
oh
Thomas Sieverding
@Bajix
Aug 10 2016 21:12
He should be doing this in system.main
the top level main is a fallback
Leath Cooper
@IcculusC
Aug 10 2016 21:12
weird, in my experience it only works under the top level package.json object
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:13
I removed it from the system object and I am getting the same result
This message was deleted
Leath Cooper
@IcculusC
Aug 10 2016 21:14
well I learned something just now
Thomas Sieverding
@Bajix
Aug 10 2016 21:14
@RALifeCoach Your paths are likely the issue
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:14
how so?
Thomas Sieverding
@Bajix
Aug 10 2016 21:15
What’s your package.json name & system.directories
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:16
my package is package.json and it’s in the same folder as build.js
not sure what you mean by system.directories
Thomas Sieverding
@Bajix
Aug 10 2016 21:16
Do you have a src folder
Or are you using a different naming convention?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:17
a different naming convention - legacy code
Thomas Sieverding
@Bajix
Aug 10 2016 21:17
What’s your main asset directory
Leath Cooper
@IcculusC
Aug 10 2016 21:17
@matthewp @justinbmeyer is it okay for me to close my issue referring to the expr.hash bug you fixed with the most recent release of can-stache-bindings
Justin Meyer
@justinbmeyer
Aug 10 2016 21:18
yeah
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:18
modules
Justin Meyer
@justinbmeyer
Aug 10 2016 21:18
@Bajix that is very rough, but check it out. Maybe lets move this convo to the forums.
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:18
modules has many sub directories - none of which use CanJS
except for the one I reference in main
Thomas Sieverding
@Bajix
Aug 10 2016 21:19
@justinbmeyer kk. I’ll do that
So you should have system.directories.lib = modules
Justin Meyer
@justinbmeyer
Aug 10 2016 21:19
On a high level, I created a behavior that you should just be able to call Todo.getList() and it should do whatever it can ... regardless if the connection is established or not
it should wait until it is
Thomas Sieverding
@Bajix
Aug 10 2016 21:20
And then your main should be “{name}/page.players-redesign/player-bio/components/player-bio.js"
Where {name} is package.json name
Ideally though, your main file would be a stache file using done-autorender
@justinbmeyer So essentially the trick would be to use the behavior to prevent any race conditions on findAll
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:22
I don’t have one of those. My html to show the component looks like this:
<!DOCTYPE html>
<html>
<head>
    <title>PGAT</title>
</head>
<body>
<script type="text/javascript" src="/js/vendor/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/js/pgatour.base.js"></script>
<script type="text/javascript" src="/js/pgatour.eventEmitter.js"></script>
<script type="text/javascript" src="/js/pgatour.baseModule.js"></script>
<script type="text/javascript" src="/js/pgatour.asyncScriptLoader.js"></script>
<script type="text/javascript" src="/js/pgatour.adTimer.js"></script>
<script type="text/javascript" src="/js/pgatour.adGroup.js"></script>
<script type="text/javascript" src="/js/pgatour.ad.js"></script>
<script type="text/javascript" src="/js/pgatour.browserActivityWatcher.js"></script>
<script src="../../../node_modules/steal/steal.js"
        main="modules/page.players-redesign/player-bio/components/player-bio"></script>
</body>
</html>
That runs okay
Thomas Sieverding
@Bajix
Aug 10 2016 21:23
You should convert that into a stache file, and make it your main instead
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:23
My package.json now includes this:
  "system": {
    "directories": {
      "lib": "modules"
    },
    "main": "pga-tour/page.players-redesign/player-bio/components/player-bio.js"
  },
But you want me to convert to stache.
Thomas Sieverding
@Bajix
Aug 10 2016 21:26
<!DOCTYPE html>
<html>
<head>
    <title>PGAT</title>
</head>
<body>
  <can-import from="./vendor/jquery-1.10.2.min"></can-import>
  <can-import from="./pgatour.base"></can-import>
  <can-import from="./pgatour.eventEmitter"></can-import>
  <can-import from="./pgatour.baseModule"></can-import>
  <can-import from="./pgatour.asyncScriptLoader"></can-import>
  <can-import from="./pgatour.adTimer"></can-import>
  <can-import from="./pgatour.adGroup"></can-import>
  <can-import from="./pgatour.ad"></can-import>
  <can-import from="./pgatour.browserActivityWatcher"></can-import>

  {{#switch env.NODE_ENV}}
    {{#case "production"}}
      <script src="{{joinBase 'node_modules/steal/steal.production.js'}}"  main="acme/index.stache!done-autorender"></script>
    {{/case}}
    {{#default}}
      <script src="/node_modules/steal/steal.js"></script>
    {{/default}}
  {{/switch}}
</body>
</html>
Something like that
You can use can-import to load stylesheets too
This part should refer to itself main="acme/index.stache!done-autorender”
Leath Cooper
@IcculusC
Aug 10 2016 21:27
is that better than using steal-css
Thomas Sieverding
@Bajix
Aug 10 2016 21:27
@IcculusC steal-css is a plugin
can-import uses plugins ;)
Justin Meyer
@justinbmeyer
Aug 10 2016 21:28
@Bajix yes, prevent race conditions, but also do anything else you need. From the outside world, it should look like calling getList like normal
Leath Cooper
@IcculusC
Aug 10 2016 21:28
ah
would the behavior of can-import not be different though since you're importing everything at once rather than bundling it with each individual component where i twouldonly be used when that component is active
Thomas Sieverding
@Bajix
Aug 10 2016 21:29
@justinbmeyer How does this work if no data matches some of the sets?
Would it try to load from the server regardless?
@IcculusC can-import behaves like require
Leath Cooper
@IcculusC
Aug 10 2016 21:31
true
Thomas Sieverding
@Bajix
Aug 10 2016 21:31
You’d essentially use can-import to load in all components/helpers being immediately used, as well as things like your main stylesheet that you wouldn’t want as a direct dependency of any components
Leath Cooper
@IcculusC
Aug 10 2016 21:32
that makes more sense
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:32
I am still getting the same crash. I have created the file index.stache. I placed it inside the modules folder. I have directories.lib = modules
Thomas Sieverding
@Bajix
Aug 10 2016 21:33
My index.stache loads in app using export-as to set it up as my can.route.data instance, my main stylesheet, can/route/pushstate/, and any components immediately being used
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:33
  "system": {
    "directories": {
      "lib": "modules"
    },
    "main": "pga-tour/index.stache"
  },
Thomas Sieverding
@Bajix
Aug 10 2016 21:33
You need the done-autorender plugin
  "system": {
    "directories": {
      "lib": "modules"
    },
    "main": "pga-tour/index.stache!done-autorender"
  },
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:37
I think there is some other problem. It still can’t find cfg.main

/git/pgatour-cq-v2/front-end/node_modules/steal-tools/lib/graph/make_graph_with_bundles.js:83
if( Array.isArray(cfg.main) ) {
^

TypeError: Cannot read property 'main' of undefined
at module.exports (/git/pgatour-cq-v2/front-end/node_modules/steal-tools/lib/graph/make_graph_with_bundles.js:83:23)

We haven’t found the magic syntax yet.
Leath Cooper
@IcculusC
Aug 10 2016 21:38
looks like it cant' find your package.json at all?
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:38
that’s a possibility
the package json is in the same folder that I’m running the node build.js from
Help??!??
Leath Cooper
@IcculusC
Aug 10 2016 21:43
I'm at a loss lol
I haven't tried building naything in production so I hve no idea
Christopher Oliphant
@RALifeCoach
Aug 10 2016 21:45
@IcculusC I appreciate your attempts to help.
Leath Cooper
@IcculusC
Aug 10 2016 21:45
hey it's a collaborative industry it's how we all learn
is that supposed to say "sausage of loose coupling"
definitely never heard that term
Thomas Sieverding
@Bajix
Aug 10 2016 22:43
Yea; that should say something more akin to "This is where we Monkey Patch."
Leath Cooper
@IcculusC
Aug 10 2016 23:09
lol
Matthew Phillips
@matthewp
Aug 10 2016 23:10
All true, but no better way that I can think of
if you want more than one map type, for example
Appreciate the feedback everyone :) Thanks for beta testing canjs 3.0
Leath Cooper
@IcculusC
Aug 10 2016 23:14
I just want to know what "sausage of loose coupling" means
sounds yummy
also sounds like someone asked whoever was writing the docs what they wanted for breakfast while they were typing them
Matthew Phillips
@matthewp
Aug 10 2016 23:28
hah, i didn't write that one, not familiar with the term
Thomas Sieverding
@Bajix
Aug 10 2016 23:29
I like my monkey patching w/ a side of sausage pl0x
Matthew Phillips
@matthewp
Aug 10 2016 23:29
it's a way for a package like can-route to be able to create Maps without depending on can-define or can-map, etc.
Christopher Oliphant
@RALifeCoach
Aug 10 2016 23:29
I am still trying to get build to work
Matthew Phillips
@matthewp
Aug 10 2016 23:30
@RALifeCoach what does your build script look like
Christopher Oliphant
@RALifeCoach
Aug 10 2016 23:30
var stealTools = require("steal-tools");

stealTools.build();
Matthew Phillips
@matthewp
Aug 10 2016 23:31
I think there's a bug, make that be
stealTools.build({ config: __dirname + "/package.json!npm" });
instead
I think config is required in the build
even though it probably shouldn't be
got to go, if that is it drop me a note so I can fix the docs tomorrow
Christopher Oliphant
@RALifeCoach
Aug 10 2016 23:32
Error loading "can/view/stache/add_bundles" at file:/git/pgatour-cq-v2/front-end/can/view/stache/add_bundles.js
Error loading "can/view/stache/add_bundles" from "done-autorender@0.8.0#autorender" at file:/git/pgatour-cq-v2/front-end/node_modules/done-autorender/src/autorender.js
ENOENT: no such file or directory, open '/git/pgatour-cq-v2/front-end/can/view/stache/add_bundles.js'
I have moved forward
Christopher Oliphant
@RALifeCoach
Aug 10 2016 23:46
But not very far forward