These are chat archives for canjs/canjs

5th
Dec 2018
Frank Lemanschik
@frank-dspeed
Dec 05 2018 02:26 UTC
@roemhildtg i have coded a contenful clone
where i created dynamic filds but with a fix set of attributes
as long as your schema stays the same like fild.name fild.type. fild.result fild.view it works perfect
i use a own component for every fild
maybe because of the additional component context i don't expirence your issue
Marc Godard
@MarcGodard
Dec 05 2018 16:35 UTC
Since I updated can-stache
Error: You can't have two versions of can-observation-recorder, check your dependencies
Matthew Phillips
@matthewp
Dec 05 2018 16:35 UTC
npm ls can-observation-recorder should tell you where the two version are coming from
Gregg Roemhildt
@roemhildtg
Dec 05 2018 16:38 UTC
I'm trying to usethis.listenTo in a setter. Is this possible?
    lookupLayers: {
        Default: DefineList,
        Type: DefineList,
        set(layers){

            this.listenTo('map', (map) => {
                 // do someting with map,
Matthew Phillips
@matthewp
Dec 05 2018 16:39 UTC
@roemhildtg I don't know... but why!
Gregg Roemhildt
@roemhildtg
Dec 05 2018 16:39 UTC
Lol
I have two properties - lookupLayers and map. Both need to be set so I can do some initialization on them
I know its sort of convoluted
Matthew Phillips
@matthewp
Dec 05 2018 16:41 UTC
why not use value()?
Gregg Roemhildt
@roemhildtg
Dec 05 2018 16:42 UTC
Perhaps. I just get confused. lookupLayers is an array of objects that need map. Would I use value in the layers or the map?
Kevin Phillips
@phillipskevin
Dec 05 2018 16:49 UTC
you have to initialize both?
if that's the case, I would probably use value for both
Gregg Roemhildt
@roemhildtg
Dec 05 2018 16:50 UTC
I just have to initialize each lookuplayer once map gets set.
Kevin Phillips
@phillipskevin
Dec 05 2018 16:50 UTC
oh
Gregg Roemhildt
@roemhildtg
Dec 05 2018 16:50 UTC
map and lookuplayers are technically set at the same time, but map is undefined when lookuplayers is set for some reaosn
Kevin Phillips
@phillipskevin
Dec 05 2018 16:50 UTC
then just use value for lookupLayers
Marc Godard
@MarcGodard
Dec 05 2018 16:50 UTC
@matthewp yes I did that and have 2 versions.
I reversed can-stache and it works. Why was this a minor update if it will break it?
Gregg Roemhildt
@roemhildtg
Dec 05 2018 16:52 UTC
You just need to delete your package-lock /node_modules and re-install. This will fix the issue you're experiencing, since it will merge all minor versions of can-observation into one.
Gregg Roemhildt
@roemhildtg
Dec 05 2018 17:03 UTC
hmm. value setter isn't working. For some reason value() isn't getting called
my viewmodel:
    //.....
    saveEdits(edits){
        this.savePromise = saveEdits(this.addressLayer, {addFeatures: edits})
    },
    lookupLayers: {
        value({lastSet, listenTo, resolve}){
            debugger; // <--- Debugger never gets called


            listenTo('map', (map) => {
Kevin Phillips
@phillipskevin
Dec 05 2018 17:05 UTC
is nothing reading lookupLayers?
Gregg Roemhildt
@roemhildtg
Dec 05 2018 17:05 UTC
Not initially
That's the issue, huh?
Kevin Phillips
@phillipskevin
Dec 05 2018 17:06 UTC
yeah
what kind of initialization do you need to do to lookupLayers
maybe it actually makes more sense to just have another property that derives from the two
Gregg Roemhildt
@roemhildtg
Dec 05 2018 17:08 UTC
I wanted to do some logging to the user, to warn them about potential configuration issues with the lookupLayers
Kevin Phillips
@phillipskevin
Dec 05 2018 17:08 UTC
hmm
maybe just do that in the connectedCallback?
Gregg Roemhildt
@roemhildtg
Dec 05 2018 17:09 UTC
okay. So connected callback is after all props are set right?
Kevin Phillips
@phillipskevin
Dec 05 2018 17:09 UTC
since it's not really related to the actual data of the viewModel, it's really just a side-effect
Gregg Roemhildt
@roemhildtg
Dec 05 2018 17:09 UTC
Right
Kevin Phillips
@phillipskevin
Dec 05 2018 17:09 UTC
connectedCallback gets called when the component is inserted
connectedCallback() {
  let map, lookupLayers;

  const doLogging = () => {
    if (map && lookupLayers) {
      // do the logging
    }
  };

  listenTo("map", (ev, m) => {
    map = m;
    doLogging();
  });

  listenTo("lookupLayers", (ev, l) => {
    lookupLayers = l;
    doLogging();
  });
}
Gregg Roemhildt
@roemhildtg
Dec 05 2018 17:20 UTC
gotcha
That'll do
Gregg Roemhildt
@roemhildtg
Dec 05 2018 17:36 UTC
Thanks!
Kevin Phillips
@phillipskevin
Dec 05 2018 17:37 UTC
you're welcome
Gregg Roemhildt
@roemhildtg
Dec 05 2018 18:11 UTC
image.png
When you see these errors, it says there's a bug in your code..but I'm not sure what would be causing it.
Looking into can-queues stack :) that is slick fyi
Paul Tichonczuk
@tracer99
Dec 05 2018 18:26 UTC
@phillipskevin We updated our old Domains Control Panel to Steal 2. Running CanJS 2.3. We're now upgrading to CanJS to 3. 3 Requires steal-stache. However, steal-stache is currently at v. 4. We were having all sorts of issues until we downgraded to 3 and now stache files "work" (well.. hopefully will work, we're still going through all the other incompatibility issues. Probably another couple of weeks).
Matthew Phillips
@matthewp
Dec 05 2018 18:29 UTC
There's a steal-stache@3
Paul Tichonczuk
@tracer99
Dec 05 2018 18:33 UTC
Yeah. That's what we used.
Dovid Bleier
@dbleier
Dec 05 2018 19:58 UTC
Anybody know of an npm packge for Google Analytics that is compatible with canjs3?
we tried universal-analytics and analytics-node but got dependency issues
Paul Tichonczuk
@tracer99
Dec 05 2018 19:59 UTC
We have Tag Manager and GA integrated in all our CanJS projects. We don't use any NPM packages for that integration. What benefit do they provide?
Dovid Bleier
@dbleier
Dec 05 2018 20:00 UTC
we wanted something we can import into the VM, and not have to add extra script tags
@tracer99 how are you integrating?
Paul Tichonczuk
@tracer99
Dec 05 2018 20:01 UTC
we just wrote a component called "scriptLoader" which loads any 3rd party scripts we need including Tag Manager
Dovid Bleier
@dbleier
Dec 05 2018 20:03 UTC
and what do you do about jshint complaining about undeclared vars (ga()) and unit tests for methods calling ga()?
Paul Tichonczuk
@tracer99
Dec 05 2018 20:05 UTC
a. we use tag manager, so don't do any direct integration with qa within our site. b. we don't use jshint because it's evil. For any global stuff, we add global entries into our eslint config.
here is our tag manager code if you want https://pastebin.com/RJJLWnns
Dovid Bleier
@dbleier
Dec 05 2018 20:10 UTC
ok, thanks
maybe this is opening a can of worms, but why do you think jshint is evil?
Paul Tichonczuk
@tracer99
Dec 05 2018 20:12 UTC
too opinionated without giving you the ability to make your own choices.
Dovid Bleier
@dbleier
Dec 05 2018 20:12 UTC
ok
Paul Tichonczuk
@tracer99
Dec 05 2018 20:13 UTC
eslint does all jshint does, but has far more config options.
Chasen Le Hara
@chasenlehara
Dec 05 2018 20:19 UTC
Heh, I thought you might be referring to JSHint’s license “The Software shall be used for Good, not Evil.” https://github.com/jshint/jshint/blob/71f2f1f08d007a9f1de0ceeaab4ebe08ef70b6f3/src/jshint.js#L19
Paul Tichonczuk
@tracer99
Dec 05 2018 20:59 UTC
Well, you can use something evil to do good 🤔