These are chat archives for canjs/canjs

25th
Jan 2018
Runn Vermel
@runn-vermel
Jan 25 2018 00:00
oh, this isn't react, i can't do an anonymous function on the call.
oy.
Runn Vermel
@runn-vermel
Jan 25 2018 00:22
that's not it, though - the selectedIndex doesn't change at all when i select a new option, so it's not a timing issue
Runn Vermel
@runn-vermel
Jan 25 2018 00:27
where can i find docs about the ($change) method? i assume an event should be passed when this is called?
Nico R.
@nriesco
Jan 25 2018 06:06
@runn-vermel try this:
include outside of the loop (#each) an option tag
{{#if mainModelPromise.isResolved}}
  <select class="form-control" value:bind="selected">
    <option value="">Select an option</option> <!— if I remove this line nothing works —>
    {{#each mainModelPromise.value}}
      <option value="someValue">{{someVar}}</option>
    {{/each}}
  </select>
{{/if}}
in my case it seems to be necessary because it is a two way binding
Frank Lemanschik
@frank-dspeed
Jan 25 2018 09:22
@phillipskevin :/ do you know the current state of on:inserted ?
are there new callbacks for can4?
i remember something but find no entry points about that
Kevin Phillips
@phillipskevin
Jan 25 2018 15:18
@runn-vermel that is just setting up a https://developer.mozilla.org/en-US/docs/Web/Events/change event
@frank-dspeed https://canjs.github.io/next/doc/migrate-4.html has a section on inserted/removed
there is a new connectedCallback, or you can add back in support for inserted
import "can-3-4-compat/dom-mutation-events";
Gregg Roemhildt
@roemhildtg
Jan 25 2018 15:31
Hey guys, I often run into this error:
Potentially unhandled rejection [2] TypeError: Cannot define property _instanceDefinitions, object is not extensible
Finding the cause isn't hard, its usually I forgot to define a property, so I usually just set a console.log breakpoint on the line with the prop name..but I think having some sort of warning for newbies would be really helpful
Kevin Phillips
@phillipskevin
Jan 25 2018 15:32
I agree - that warning is really unhelpful
can you open an issue in can-define?
we should be able to give the name of the prop and the name of the DefineMap
Gregg Roemhildt
@roemhildtg
Jan 25 2018 15:34
Yep, will do.
Gregg Roemhildt
@roemhildtg
Jan 25 2018 15:44
canjs/can-define#309
Gregg Roemhildt
@roemhildtg
Jan 25 2018 16:23
Anyone ever created a "batch save" method in can-connect? Instead of model.save(oneItem) saving multiple items in one requestmodel.save([item1, item2, item3]);?
I gotta create about a thousand records in one go...and I think calling .save x1000 would not be pretty
feathersClient accepts an array of data though...so maybe a custom behavior with a special function like saveBatch would be the way to go.
sound about right?
Nico R.
@nriesco
Jan 25 2018 16:57
@roemhildtg the Potentially unhandled rejecttion … object is not extensible error occurs when that variable is not defined in the viewmodel
usually happens when you are trying to get a property from the wrong place
Kevin Phillips
@phillipskevin
Jan 25 2018 16:58
the problem he is pointing out is that _instanceDefinitions is not the name of the property that is being set
Nico R.
@nriesco
Jan 25 2018 16:58
or you just forgot to define it, I think the difficutly is that it only occurs when trying to save or when you don’t load an inital content
Oh, I see
Gregg Roemhildt
@roemhildtg
Jan 25 2018 16:59
Hey, calling a definMap.get should return all its properties, right? Even if serialize:false is set on a property?
Or does serialize: false affect .get() as well as .serialize()?
Kevin Phillips
@phillipskevin
Jan 25 2018 17:11
get also just returns enumerable properties
Runn Vermel
@runn-vermel
Jan 25 2018 17:14
@phillipskevin - the problem is that i can't data bind it - long story. there's something that's preventing the select from knwoing there's been a change in the option selected. i know (vaguely) that canJs has something that adds a value property to a select - but that doesn't seem to get updated. it knows there's a change, but the value on the select doesn't change, so i was hoping that maybe there's a way to access the change event that is generated with the ($change) function call
Gregg Roemhildt
@roemhildtg
Jan 25 2018 17:14
Okay gotcha.
Kevin Phillips
@phillipskevin
Jan 25 2018 17:19
<select> has value without CanJS
Runn Vermel
@runn-vermel
Jan 25 2018 17:20
@phillipskevin i humbly disagree: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select - it has selectedIndex but no value.
that's why I tried it in the JSBin... because it wasn't readily available on the docs you pointed out
it's in the DOM Interface link though
Runn Vermel
@runn-vermel
Jan 25 2018 17:23
ha - thanks MDN. 2 docs for the same thing with different attributes on them. either way, value isn't being updated when i make a new selection... any ideas?
Kevin Phillips
@phillipskevin
Jan 25 2018 17:23
the value isn't? or the property you're binding it to isn't?
Runn Vermel
@runn-vermel
Jan 25 2018 17:24
the value isn't
i can't bind to a property because of how the data is structured.
so, i just wanna be notified when there's a change, and check for the (hopefully) changed value, and act accordingly
Kevin Phillips
@phillipskevin
Jan 25 2018 17:25
  <select class="form-control"
          {($value)}="trainsByPlatform[platform.name]"
          ($change)="upsertInitialRelease(platform.name, scope.element.value)">
    <option></option>
    {{#each trains[platform.name] as train}}
    <option value="{{train.name}}">{{train.name}}</option>
    {{/each}}
  </select>
is that the code you have?
Runn Vermel
@runn-vermel
Jan 25 2018 17:25
yup
Kevin Phillips
@phillipskevin
Jan 25 2018 17:25
and you're saying that upsertInitialRelease isn't being called?
Runn Vermel
@runn-vermel
Jan 25 2018 17:26
it is, but scope.element.value is NEVER changed
Kevin Phillips
@phillipskevin
Jan 25 2018 17:26
ok
so... I would first change {($value)} to be only one-way bound
{$value}
so you only have one handler element->viewModel and one handler viewModel->element
right now you have a two-way binding and a one-way binding
Runn Vermel
@runn-vermel
Jan 25 2018 17:27
at first we thought perhaps it was a timing issue - but it NEVER changes, and the select doesn't actaully show the new option - it always stays at the empty first option
Kevin Phillips
@phillipskevin
Jan 25 2018 17:28
did you try changing it to
          {$value}="trainsByPlatform[platform.name]"
          ($change)="upsertInitialRelease(platform.name, scope.element.value)">
Runn Vermel
@runn-vermel
Jan 25 2018 17:28
OMG. that was... simple. of course - doing it 1 way means it can update itself...
Kevin Phillips
@phillipskevin
Jan 25 2018 17:29
oh, that was it?
Runn Vermel
@runn-vermel
Jan 25 2018 17:30
i'm reloading, just to be sure :)
yes, that was totally it. big sigh of relief
Kevin Phillips
@phillipskevin
Jan 25 2018 17:31
ok cool. maybe we should warn if you have multiple of the same binding. I don't know if that would ever be something you want.
Runn Vermel
@runn-vermel
Jan 25 2018 17:31
lol.
ok, since i got your attention (your awesome), those warnings are back. i have 100s of them
Kevin Phillips
@phillipskevin
Jan 25 2018 17:32
which warnings specifically?
Runn Vermel
@runn-vermel
Jan 25 2018 17:33
%index is deprecated. Use scope.index instead.
whoa, that's not it. sorry
can-stache-bindings: the event binding format ($click) is deprecated. Use on:click instead
Kevin Phillips
@phillipskevin
Jan 25 2018 17:35
oh, yeah, those are deprecated
(and removed in 4.0, which will be released very soon)
Runn Vermel
@runn-vermel
Jan 25 2018 17:36
yeah. so is this app - we are building a now one - i don't want to go through and change things - just turn of the 100s of warnings i'm getting...
Runn Vermel
@runn-vermel
Jan 25 2018 17:36
i added this:
import CanLog from "can-log";
CanLog.logLevel = 99;
and i swear that worked for about an hour, and then they came back.
Kevin Phillips
@phillipskevin
Jan 25 2018 17:36
hmm
Runn Vermel
@runn-vermel
Jan 25 2018 17:36
which... ok? weird.
Kevin Phillips
@phillipskevin
Jan 25 2018 17:36
depends where you add that I think
Runn Vermel
@runn-vermel
Jan 25 2018 17:36
index.js
at my root
Kevin Phillips
@phillipskevin
Jan 25 2018 17:37
ok
Runn Vermel
@runn-vermel
Jan 25 2018 17:37
at the end of the imports. should i try at the beginning?
ok, that did nothing.
Kevin Phillips
@phillipskevin
Jan 25 2018 17:37
first, I would break in can-log inside of warn
and see if this.logLevel is 99
Runn Vermel
@runn-vermel
Jan 25 2018 17:38
how do i do that?
Kevin Phillips
@phillipskevin
Jan 25 2018 17:39
in chrome devtools, type cmd+p (or ctrl+p for windows)
type in can-log
Runn Vermel
@runn-vermel
Jan 25 2018 17:39
(also, i have to get off my bus in about 5 minutes, so, i'll be back later. thanks so much for your help!)
Kevin Phillips
@phillipskevin
Jan 25 2018 17:39
find the warn function and click on the line number on the left to add a breakpoint
my guess is you have multiple versions of can-log... and the one you're setting the logLevel on isn't the one we're using
(this isn't a great way of removing the logs)
Runn Vermel
@runn-vermel
Jan 25 2018 17:40
oh! i'm open to the best way ;)
Kevin Phillips
@phillipskevin
Jan 25 2018 17:40
well... there isn't really a best way... other than fixing them
Runn Vermel
@runn-vermel
Jan 25 2018 17:41
you can understand why i don't have time to fix a super old app that's being replaced ;)
Kevin Phillips
@phillipskevin
Jan 25 2018 17:41
I do understand, yeah
I definitely get that it's annoying... I just don't have a better answer for you right now
Runn Vermel
@runn-vermel
Jan 25 2018 17:41
you're right - this.logLevel returned 0
totally.
Kevin Phillips
@phillipskevin
Jan 25 2018 17:42
npm ls can-log
try to match your version with whatever version your can-* dependencies are using
so there is only one
Runn Vermel
@runn-vermel
Jan 25 2018 17:42
│ ├─┬ can-stache-key@0.1.3
│ │ └── can-log@0.1.2  deduped
│ ├─┬ can-types@1.1.5
│ │ └── can-log@0.1.2  deduped
│ └─┬ can-view-scope@3.5.5
│   └── can-log@0.1.2  deduped
├── can-log@0.1.2 
├─┬ can-route@3.3.2
│ └── can-log@0.1.2  deduped
├─┬ can-stache@3.14.8
│ ├─┬ can-attribute-encoder@0.3.3
│ │ └── can-log@0.1.2  deduped
│ ├── can-log@0.1.2  deduped
│ └─┬ can-view-parser@3.8.0
│   └── can-log@0.1.2  deduped
├─┬ can-stache-bindings@3.11.9
│ └── can-log@0.1.2  deduped
├─┬ can-util@3.11.0
│ └── can-log@0.1.2  deduped
└─┬ steal-stache@3.0.5
  └─┬ can-view-import@3.2.7
    └── can-log@0.1.2  deduped
ok, getting off the bus - have no idea how to change it to only one - it seems like they are all using the same version though
Kevin Phillips
@phillipskevin
Jan 25 2018 17:44
ok, yeah, that looks fine
so... you need to make your CanLog.logLevel = 99; run earlier
Frank Lemanschik
@frank-dspeed
Jan 25 2018 22:34
@kevin this migration guide is like gold :)
it should get more highlighted
:D
but good to know that canJs was intuitiv enough for me already to get it rendering i am happy with can4
i also got feathers 3 working maybe just finishing the last tests
and test all situations but it looks that socketio 2 with feathers 3 is working with ssr
CanJS 4's is really epic because of the great automount concept using webcomponents i hope we get webcomponents stuff into canjs 5 even more
so that canjs is simply the better polymer
Nico R.
@nriesco
Jan 25 2018 22:43
@runn-vermel @phillipskevin I’m confused with the select issue, was it solved with one way binding? If that is the case, it won’t work for me because I use it both to set the value when selecting and to load the initial value. Is that possible using your solution? @runn-vermel can you share the code? thanks
@frank-dspeed would that work with canjs 3? any shareable code? :-)
Frank Lemanschik
@frank-dspeed
Jan 25 2018 22:44
feathers 3 will work with can 3 but its more hard to debug then
at present i have it running in some diffrent ways
but the most importent info is maybe that can-connect-feathers v2
even still works
i think the warning that it don't works comes from the new feathers 3 channel integration part
if your using feathers3 server side you need to let it handle where to publish updates
  app.on('connection', connection => {
    // On a new real-time connection, add it to the anonymous channel
    app.channel('anonymous').join(connection);
  });
  // Lets publish to anyone at present
  app.publish(() => {    app.channel('anonymous');  });
so this 2 things need to get added to get the old canjs behaviers working out of the box
as this makes sure that every connected client joins a channel called anonymous
and all in channel anonymouse get all update created removed events
as it was befor
this was the default behavior of feathers 2
Frank Lemanschik
@frank-dspeed
Jan 25 2018 22:56
and about the ssr socket.io part
i used can-zone Zone(io)
it ignores can zone
but works
Runn Vermel
@runn-vermel
Jan 25 2018 23:13
@nriesco yeah, making it one way bind allowed the change to be reflected in the UI - that's all i did.
@phillipskevin ok, i have a new issue now: inside can-define/define-helpers/define-helpers.js Chrome dev tools has paused with the following message: "Paused before potential out-of-memory crash" - it paused on map.each call on line 126
the array it's mapping through only has 130 items, so, not huge.
@justinbmeyer ^ any ideas?
Kevin Phillips
@phillipskevin
Jan 25 2018 23:31
@nriesco it is really two one-way binds
          {$value}="trainsByPlatform[platform.name]"
          ($change)="upsertInitialRelease(platform.name, scope.element.value)">
one-way binding in each direction
@runn-vermel can you send a link to the line in the code?
Justin Meyer
@justinbmeyer
Jan 25 2018 23:51
nope, that should be ok ... maybe possible recursion, an item that has itself