These are chat archives for canjs/canjs

7th
Dec 2018
Manuel Mujica
@m-mujica
Dec 07 2018 00:20

Question related to can-query-logic "Ignoring keys" warning. I have a a request like:

Todo.get({ keyA: 'bar' })

the Todos in the response do not include keyA... and I get the warning:

can-log.js:98 can-query-logic: Ignoring keys: keyA.

I'm guessing this is one of the cases where the warning is bad, since real-time won't be able to update my lists (given that keyA is part of the listQuery).
Any suggestions on how to handle this?

Chasen Le Hara
@chasenlehara
Dec 07 2018 00:48
@m-mujica This doesn’t answer your question, but might point you in the right direction: canjs/can-query-logic#25
Justin Meyer
@justinbmeyer
Dec 07 2018 01:06
@m-mujica this is with a get not a getList?
Only getList should use querylogic
Justin Meyer
@justinbmeyer
Dec 07 2018 03:03
Frank Lemanschik
@frank-dspeed
Dec 07 2018 04:40
@phillipskevin https://canjs.com/doc/guides/logic.html#Cleanupeventlisteners can you clarify this point?
it shows returning a callback but also says it will cleanup the listenTo
but it will not call stopListining method as we return a callback
is that correct?
Kevin Phillips
@phillipskevin
Dec 07 2018 04:41
that first example does not return a callback
  connectedCallback() {
    // this will be cleaned up automatically
    listenTo("name", () => {
      // ...
    });
  }
nothing is returned
Frank Lemanschik
@frank-dspeed
Dec 07 2018 04:42
Clean up listeners in a value definition
look at that example

The same technique can be used to clean up listeners set up in a value definition. A function returned from the value function will be called when that property is no longer bound.

Event listeners set up using listenTo in a value definition will be cleaned up automatically. Other listeners should be cleaned up manually.

Here is an example:

// DERIVED PROPERTIES
    namedCounter: {
      value({ listenTo, resolve }) {
        let count = 0;
        let name = this.name;

        resolve(`${name}: ${count}`);

        let timeoutId = setInterval(() => {
          count++;
          resolve(`${name}: ${count}`);
        }, 1000);

        listenTo("name", (ev, n) => {
          name = n;
          resolve(`${name}: ${count}`);
        });

        return () => {
          clearTimeout(timeoutId);
        };
      }
    }
it returns clearTimeout in a anonym function
Kevin Phillips
@phillipskevin
Dec 07 2018 04:43
yes, so listenTo in a value definition is different from DefineMap.prototype.listenTo
Frank Lemanschik
@frank-dspeed
Dec 07 2018 04:43
and says in the description that listenTo gets cleaned up
Kevin Phillips
@phillipskevin
Dec 07 2018 04:44
listenTo in a value defintion will always be cleaned up automatically
Frank Lemanschik
@frank-dspeed
Dec 07 2018 04:44
do you know where this listenTo is implamented?
Kevin Phillips
@phillipskevin
Dec 07 2018 04:44
the one for value defintions?
Frank Lemanschik
@frank-dspeed
Dec 07 2018 04:44
yes
Frank Lemanschik
@frank-dspeed
Dec 07 2018 04:45
can you maybe tell me how you find such stuff so fast?
:D
do you got a personal map or a search algo for that?
Kevin Phillips
@phillipskevin
Dec 07 2018 04:46
nope
I knew what it was called
Frank Lemanschik
@frank-dspeed
Dec 07 2018 04:46
so you really know that ok perfect
Kevin Phillips
@phillipskevin
Dec 07 2018 04:46
and found the package
Frank Lemanschik
@frank-dspeed
Dec 07 2018 04:47
ok i need to play with that api maybe also :)
Kevin Phillips
@phillipskevin
Dec 07 2018 04:47
sometimes I search the built file
if I'm really not sure where to start
Frank Lemanschik
@frank-dspeed
Dec 07 2018 04:47
also a good idea less jumping between files
amazing :)
simple but i simply don't tought about that
so value === simple-observable
so i could adopt this way Fantasy Land and Static Land Algebras
fantastic
we got our streaming ViewModel
:D
Kevin Phillips
@phillipskevin
Dec 07 2018 04:52
value === ResolverObservable
Frank Lemanschik
@frank-dspeed
Dec 07 2018 04:54
yes your right but can-simple-observable returns module.exports = ResolverObservable;
so its also === can-simple-observable
but anyway nice nice this should be all code thats needed
as we can return a value and modify it
so we can constant return stream changes
for binding we simply can use dom event streams
export const change = (node, capture = false) => domEvent('change', node, capture)
export const select = (node, capture = false) => domEvent('select', node, capture)
export const submit = (node, capture = false) => domEvent('submit', node, capture)
export const keydown = (node, capture = false) => domEvent('keydown', node, capture)
export const keypress = (node, capture = false) => domEvent('keypress', node, capture)
i was always trying to understand this symbols for canreflect
now i can use this code with some little changes and its integrated
its better then the fromCompute => Stream=>toCompute method
Chasen Le Hara
@chasenlehara
Dec 07 2018 16:30
We’ll be LIVE in a few minutes with our bi-weekly contributors meeting, where we demo what we’ve been working on and get nerdy about technical topics: https://www.youtube.com/watch?v=z6a7u6GFmlU
Justin Meyer
@justinbmeyer
Dec 07 2018 19:20
Here's a nice demo of using custom elements to know when to load items in the page: https://codepen.io/justinbmeyer/pen/JwPOGK?editors=0111
Frank Lemanschik
@frank-dspeed
Dec 07 2018 20:23
@justinbmeyer https://www.youtube.com/watch?v=cznVISavm-k a must watch if you was not directly at JSConf
there is the push or not to push talk