These are chat archives for canjs/canjs

12th
Jan 2017
lmagarian
@lmagarian
Jan 12 2017 00:35
I'm working through the ATM guide and wonder about the following stash syntax. What is the difference between {{}} and (${{}}) as in
{{currentTransaction.account.name}}
(${{currentTransaction.account.balance}})
Kevin Phillips
@phillipskevin
Jan 12 2017 00:38
the $ isn't part of the syntax
it's just so the balances have a dollar sign before them
same with the ()
lmagarian
@lmagarian
Jan 12 2017 00:38
ok :) thanks
Kevin Phillips
@phillipskevin
Jan 12 2017 00:38
no problem
lmagarian
@lmagarian
Jan 12 2017 00:39
how about these ... {($value)} ($click) ?
Kevin Phillips
@phillipskevin
Jan 12 2017 00:40
in those, the $ indicates its a property on the DOM
lmagarian
@lmagarian
Jan 12 2017 00:40
and the {}?
Kevin Phillips
@phillipskevin
Jan 12 2017 00:40
lmagarian
@lmagarian
Jan 12 2017 00:41
thanks
Kevin Phillips
@phillipskevin
Jan 12 2017 00:41
:thumbsup:
Nico R.
@nriesco
Jan 12 2017 00:48
Same topic: what is the difference between {{this}} and {{.}} ?
Kevin Phillips
@phillipskevin
Jan 12 2017 00:49
nothing
seasoup
@seasoup
Jan 12 2017 01:15
I'm trying to access attributes passed into a component in the ViewModel in a stache file. It works when the viewModel is { test: 1 } and the stache is {{test}} but it does not work when the view model is { test: { nested: 1 } } and the stache is {{test.nested}}. Do I have to do something special for nested values?
Kevin Phillips
@phillipskevin
Jan 12 2017 01:18
you shouldn't need to
what doesn't work with the nested value?
seasoup
@seasoup
Jan 12 2017 01:18
accessing it
{{test.nested}} gives the error
"can-stache/src/expression.js: Unable to find key or helper \"test.nested\"."
Kevin Phillips
@phillipskevin
Jan 12 2017 01:20
and it doesn't show up on the screen?
seasoup
@seasoup
Jan 12 2017 01:20
nope
Kevin Phillips
@phillipskevin
Jan 12 2017 01:20
can you create a JSBin?
there's a link at the top of the Gitter chat with a starter
seasoup
@seasoup
Jan 12 2017 01:27
im a bit confused with the new view models because its not the instantiated object that is getting passed in.
how do I set all the attributes on it before I pass it in?
Kevin Phillips
@phillipskevin
Jan 12 2017 01:33
I'm not sure I understand what you mean
seasoup
@seasoup
Jan 12 2017 01:34
in can 2.x I would do
var HomeViewModel = {foo:"bar"}
and in the component do:
scope: HomeViewModel and access it in the state with {{foo.bar}}
now it's passing in a can.DefineMap.extend({page: 'string'});
which is an uninstantiated DefineMap
with an attribute called page which is a string
Kevin Phillips
@phillipskevin
Jan 12 2017 01:37
yes, that's just creating the constructor function
seasoup
@seasoup
Jan 12 2017 01:37
right and the constructor function is passed into the component viewModel
so I can't define any attributes.
Kevin Phillips
@phillipskevin
Jan 12 2017 01:37
so set it with ViewModel
seasoup
@seasoup
Jan 12 2017 01:37
how?
Kevin Phillips
@phillipskevin
Jan 12 2017 01:37
you want default values you mean?
seasoup
@seasoup
Jan 12 2017 01:38
I suppose so
Kevin Phillips
@phillipskevin
Jan 12 2017 01:39
you can do that in your extend like
can.DefineMap.extend({
    page: {
        type: 'string',
        value: 'bar'
    }
});
or when you create the component <my-comp page="bar"></my-comp>
seasoup
@seasoup
Jan 12 2017 01:39
and what if page is an object with attributes?
Kevin Phillips
@phillipskevin
Jan 12 2017 01:47
the first way will still work
  page: {
    value:{ bar: 'baz' }
  }
I'm not sure if you can pass an object as an attribute
seasoup
@seasoup
Jan 12 2017 01:53
The obj in question is a supermap, so I set it to the class and it's almost working
the fixture doesn't seem to be returning something even though it is intercepting the query.

var EventMap = superMap({
idProp: "id",
Map: Event,
List: Event.List,
url: "/api/event/",
name: "Event"
});

var eventStore = fixture.store([
{ id: 1, name: "event 1" },
{ id: 2, name: "event 2" },
{ id: 3, name: "event 3" }
]);

fixture( "/api/event/{id}", eventStore );

seasoup
@seasoup
Jan 12 2017 02:13
figured out, store was missing Algebra whatever that is...
thanks for your help tonight
Gregg Roemhildt
@roemhildtg
Jan 12 2017 14:08
Is there a way to set the debug mode in canjs so that messages get logged even in steal bundled production mode? I'm running into an issue where my app isn't behaving correctly in production but no messages are getting logged to the console.
Adam L Barrett
@BigAB
Jan 12 2017 16:14
Not to distract from that question (to which I don't know the answer), but here is another question:
Is it intentional or a bug that the setter/transfrom type of compute doesn't "observe" inner computes (or whatever) and so doesn't update the value when internal computes change?
https://jsbin.com/vevusi/edit?js,output
(Trying to decide if I should file an issue or not)
Justin Meyer
@justinbmeyer
Jan 12 2017 16:15
@roemhildtg there might be a way when you are building your app w/ steal
Matthew Phillips
@matthewp
Jan 12 2017 16:15
I don't know for sure but definitely sounds like a bug
@BigAB
would file an issue for that
Justin Meyer
@justinbmeyer
Jan 12 2017 16:16
being lazy .. where is the "transform" compute?
factor2andProduct ?
@BigAB
Adam L Barrett
@BigAB
Jan 12 2017 16:18
Yeah, didnt know what to call it, the compute-initialvalue-setternewvaloldval compute signature https://github.com/canjs/can-compute/tree/v3.0.5#compute-gettersetter-context-
Whoops I mean compute-initialvalue-setternewvaloldval
Justin Meyer
@justinbmeyer
Jan 12 2017 16:19
Why are you using it?
it's for pure "set" behavior
only the "getter / setter" form of compute actually does 'compute' type logic
Adam L Barrett
@BigAB
Jan 12 2017 16:20
I was trying to use it as a way to remove the need for an extra compute
Justin Meyer
@justinbmeyer
Jan 12 2017 16:20
and async
can you expand on that use case?
@roemhildtg removeDevelopmentCode of http://stealjs.com/docs/steal-tools.BuildOptions.html
Matthew Phillips
@matthewp
Jan 12 2017 16:24
So we should update the docs to clarify that only the getter/setter updates itself based on observations.
Justin Meyer
@justinbmeyer
Jan 12 2017 16:24
the compute(init, SETTINGS}) doesn't do it either
Gregg Roemhildt
@roemhildtg
Jan 12 2017 17:32
@justinbmeyer thanks, I will look into that
Gira Minus
@gKreator
Jan 12 2017 18:40
when using a DefineMap, what is the best way to listen to changes on child objects?
Kevin Phillips
@phillipskevin
Jan 12 2017 18:41
you want to know when any property of the child changes? or only specific changes?
Gira Minus
@gKreator
Jan 12 2017 18:42
specific changes
so like user.settings.color
Kevin Phillips
@phillipskevin
Jan 12 2017 18:43
ok, and what do you want to happen when that changes?
Gira Minus
@gKreator
Jan 12 2017 18:44
fire any function really
Kevin Phillips
@phillipskevin
Jan 12 2017 18:45
you should be able to just add this.user.settings.color to whatever function you want to rerun
Gira Minus
@gKreator
Jan 12 2017 18:45
your talking about using get?
Kevin Phillips
@phillipskevin
Jan 12 2017 18:47
if you did that in a get it would update when user.settings.color changes, yes
I’m probably not answering your question
Gira Minus
@gKreator
Jan 12 2017 18:50
if im not using the get in a stache template... what is the best way to trigger it so it listens to changes? just use it as this.viewModel.userSettingsColorChange(); and it will just run every time the color changes?
at this point i may as well be using http://canjs.com/doc/can-define/map/map.prototype.on.html ?
Kevin Phillips
@phillipskevin
Jan 12 2017 18:53
yeah, that’s what I was going to say
Gira Minus
@gKreator
Jan 12 2017 18:53
wait... unless I nest a DefineMap?
Kevin Phillips
@phillipskevin
Jan 12 2017 18:53
I’m still not totally sure what problem you’re trying to solve
Gira Minus
@gKreator
Jan 12 2017 18:54
yeah sorry its hard to explain things sometimes
Kevin Phillips
@phillipskevin
Jan 12 2017 18:54
yeah, it’s ok
Gira Minus
@gKreator
Jan 12 2017 18:54
blob
long story short... i really like that syntax
Kevin Phillips
@phillipskevin
Jan 12 2017 18:55
ok
what’s wrong with that?
also, why not just do it with a get?
get notes_live() {
    return this.tasks.notes;
}
Gira Minus
@gKreator
Jan 12 2017 18:56
nothing, I was just wondering how to listen to changes using set on nested objects... but I guess the only way to do that is to nest a DefineMap
Kevin Phillips
@phillipskevin
Jan 12 2017 19:00
DefineMap is trying to make it so you don’t have to explicitly listen to changes
by doing it for you
Gira Minus
@gKreator
Jan 12 2017 19:01
yeah, that I kidna understand I just dont know DefineMap as well as I should
blob
that is a long and complicated answer :D
but that would work
Nico R.
@nriesco
Jan 12 2017 19:58
When using MyModel.getList({param1: value1}) is it possible to access the total number of results that a feathersjs-based API will generate? like this one:
"total": 647,
"limit": 25,
"skip": 1,
"data": [{
  "_id": "58766dcd6f7cda2cffe82081",
  "price": 122,
  "active": true,
  "__v": 0,
  "updatedAt": "2017-01-11T17:39:25.824Z",
  "createdAt": "2017-01-11T17:39:25.824Z"
}]
I do have access to everything inside data
but in order to access total for instance I would need to do a “manual” get instead of just using the model
maybe something like:
{{#each myPromise.value}} ====> {{#each myPromise.headers}}
Kevin Phillips
@phillipskevin
Jan 12 2017 20:06
I don’t know of an out of the box way to do that
you can create your own behavior that implements getListData and provides the count
not sure if can-connect-feathers makes this any easier. cc @marshallswain
Gregg Roemhildt
@roemhildtg
Jan 12 2017 20:25
Not sure if this is the best way, but I add a metadata object to the can-connect object. I override the getListData completes, and set a total property on the metadata object.
basically what @phillipskevin said I think
Kevin Phillips
@phillipskevin
Jan 12 2017 20:27
sounds right to me
Gregg Roemhildt
@roemhildtg
Jan 12 2017 20:28
seasoup
@seasoup
Jan 12 2017 22:25
in canjs 3, whats the right object to use for a user where the only behavior is to send a GET request to a url which will return an object of the currently logged in user?