These are chat archives for canjs/canjs

1st
Jul 2018
Justin Meyer
@justinbmeyer
Jul 01 2018 01:57

@qantourisc

hmmm can I still observe an entire Map ?

What do you mean? You can still use can-map and do pretty much everything with it

if you are updating, I wouldn't switch to DefineMap right away. can-map still works
You shouldn't use SimpleMap ... it's an internal thing
Have you been following the 3.0 migration guide: https://canjs.com/doc/migrate-3.html
Eben
@eben-roux
Jul 01 2018 07:59
How would one go about passing the view model of a parent component to a child component?
qantourisc
@qantourisc
Jul 01 2018 08:47
@eben-roux you might be looking for scopeLeak instead ?
I don't know about CanJS3/4 but iirc in 2 you could also do something like parent_scope:bind="."
. being the current context
Personally I avoid it, and just feed it what it needs
like did you need to pass the current page/offset ? Make a map "Paginator" create an instance in the parent, and bind it to the child
Eben
@eben-roux
Jul 01 2018 08:50
thanks... seems as though leakScope may do the trick
in my case I have a component wrapped up in another one that just adds a label so quite a bit of mapping
but it may be worthwhile just passing the bits down
qantourisc
@qantourisc
Jul 01 2018 08:58
I'd need to see an example to really get it though. There might be a better way ?
qantourisc
@qantourisc
Jul 01 2018 09:09
I currently do somrething nasty :D
qantourisc
@qantourisc
Jul 01 2018 09:27
isResolved is gone, replace with .then( this.attr("is_resolved",true) ?
qantourisc
@qantourisc
Jul 01 2018 10:18
@eben-roux I am running in a simular problem now
in my case subcomponent isn't taking in the scoipe
A the parent needs to leak the scope
qantourisc
@qantourisc
Jul 01 2018 10:40
Is there a way to leakScope on a single subelement ? (as the scope is the scope of a #each
qantourisc
@qantourisc
Jul 01 2018 11:31
@eben-roux root:bind="." might also help you
Justin Meyer
@justinbmeyer
Jul 01 2018 11:32

What do you mean by:

as the scope is the scope of a #each

qantourisc
@qantourisc
Jul 01 2018 11:32
{{#each list}}<my-component everything_please:bind="."/> {{/each}}
Justin Meyer
@justinbmeyer
Jul 01 2018 11:33
that should work, does that not?
qantourisc
@qantourisc
Jul 01 2018 11:33
it does, but I'd like to replace everything_please with "." :D
Thomas Sieverding
@Bajix
Jul 01 2018 11:34
What would the property name be on the view model then
qantourisc
@qantourisc
Jul 01 2018 11:34
the items in the list are Maps.
or I enable leakscope
Justin Meyer
@justinbmeyer
Jul 01 2018 11:35
I think you are wanting <my-component this:assignFrom="."> canjs/can-stache#505
qantourisc
@qantourisc
Jul 01 2018 11:36
@eben-roux ^^
Justin Meyer
@justinbmeyer
Jul 01 2018 11:38
This isn't supported yet, it needs to get some more votes in the survey
image.png
qantourisc
@qantourisc
Jul 01 2018 11:38
oh
So I should just leak then ?
or type more
Justin Meyer
@justinbmeyer
Jul 01 2018 11:39
did you try this:from="."
I feel like @chasenlehara said this was working ... but I'm not sure
if not, I'd leak for now ... btw, if someone wants to pair with us to land this feature (or pretty much any feature), we are always available
qantourisc
@qantourisc
Jul 01 2018 11:39
It is working, even for :bind
Justin Meyer
@justinbmeyer
Jul 01 2018 11:39
this one isn't very hard ...
Justin Meyer
@justinbmeyer
Jul 01 2018 11:45
I can pseudo code one up later today if someone is interested
qantourisc
@qantourisc
Jul 01 2018 11:46
I'm not sure what you are asking/suggesting/offering ? making this:from="." work ? it does
can-stache/expressions/lookup.js: Unable to find key "order_by". <= Would be nice to know where that errors occurs ;)
Well without using a callstack, but there is no good way
Eben
@eben-roux
Jul 01 2018 12:16
after updating to the latest canjs component I'm getting the following warning:
image.png
Eben
@eben-roux
Jul 01 2018 12:33
is there a quick way to invert a boolean binding?
for instance: I have disabled:from="canRestart"
but I'd prefer disabled:from="!canRestart" or some such as opposed to having the attribute named cannotRestart
Mohamed Cherif Bouchelaghem
@cherifGsoul
Jul 01 2018 13:17
@eben-roux you can write your own binding with can-view-attr
@eben-roux I think this is what are you looking for https://canjs.com/doc/can-stache-converters.not.html
Nico R.
@nriesco
Jul 01 2018 14:31

thanks... seems as though leakScope may do the trick

@eben-roux @qantourisc I believe that leakScope is not the solution but using a shared instance would be a better approach: https://forums.donejs.com/t/having-a-shared-instance-object/800

Justin Meyer
@justinbmeyer
Jul 01 2018 15:48
@eben-roux I’ve created a ‘not’ converter
@qantourisc if you are on latest, it should tell you the file and line
Any 4.0 should
@eben-roux that warning means you have a cycle in a binding where parent and child keep trying to set each other. Behavior hasn’t changed, we are adding a warning to let people know when this happens
@qantourisc offering to make assignFrom work
Eben
@eben-roux
Jul 01 2018 18:00
thanks for all the info folks!
@Justin: I have a situation where two attributes do update each other but I prevent a cycle using a flag. Would canjs still report that? Although, perhaps I buggered up somewhere... I'll have to take another look
Justin Meyer
@justinbmeyer
Jul 01 2018 18:39
I don't think it would report it if you prevented it. It's not able to detect if a cycle exists, only when one happens.