These are chat archives for canjs/canjs

26th
Apr 2017
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 18:38
Hey everyone,
I need help, my coworker is trying to turn off the instance store. Any advise or documentation you can send my way to give to him?
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 18:41
In the constructor/store/ behavior of can-connect?
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 18:42
yeah
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 18:43
Are you using a custom set of behaviors, or superMap?
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 18:43
custom
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 18:44
Can you just remove the behavior, then?
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 18:52
dependencies on store?
I am getting an error in callbacks-once that is trying to use this.getInstanceMetaData
map also has references to addListReference which then no longer exists. I don't think store can be removed...
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 18:55
Mm, I see. You can always reimplement any dependencies that crop up with stub functions.
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 18:56
hahaha
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 18:57
var stubConnections = connect.behavior(function(baseConnection) {
    return {
      getInstanceMetaData: function() { return {} },
     addListReference: function() {}
   }
}
Also please file bug reports about the faux modularity. We (as devs at Bitovi) are also concerned about it and your voices help amplify ours.
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 19:02
sure, thanks for the help!
Kevin Phillips
@phillipskevin
Apr 26 2017 19:02
it would also be helpful to know why you want to turn off the instance store
Frank Lemanschik
@frank-dspeed
Apr 26 2017 19:06
does some one maybe knows what object steal exports?
i would love to find the vars that i set for example in a index.js file loaded by steal
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 19:07
we are getting a list of objects, we then have a list relationship on the object that is filterable in our api and that is not playing nicely with stores.
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:11
@frank-dspeed can you give me an example of such an index.js file?
I may be misunderstanding your question, but steal always uses the format of your file, so if it's CommonJS style (using require() to load imports), then steal exports module.exports from that file.
Frank Lemanschik
@frank-dspeed
Apr 26 2017 19:13
@bmomberger-bitovi sure var omniTest = "anyString"
now i want to access that some how but i don't found it on the window object
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:14
I see now. When your script is loaded as a module, varat the top level doesn't mean "global". Those vars are only local to the script.
Steven Vachon
@stevenvachon
Apr 26 2017 19:14
this the correct channel for npmjs.com/testee ?
Frank Lemanschik
@frank-dspeed
Apr 26 2017 19:14
@bmomberger-bitovi ok so how to export them
simply assign them on window.omniTest ?
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:15
export var omniTest = "anyString" will allow you to import them into other scripts.
Frank Lemanschik
@frank-dspeed
Apr 26 2017 19:15
so you think i can access them then via console?
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:15
window.omniTest = "anyString" will make it global if your platform uses window as the global
Kevin Phillips
@phillipskevin
Apr 26 2017 19:16
@stevenvachon https://gitter.im/bitovi/testee is the right place
Steven Vachon
@stevenvachon
Apr 26 2017 19:16
ok, thank you
Frank Lemanschik
@frank-dspeed
Apr 26 2017 19:16
ok lets hope that this works
that would help a lot :)
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:16
Yes, to access an export in a module from the console, you can do this:
System.import('my-module-path').then(function(module) { window.MyExportName = module.myExportName })
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 19:17

@phillipskevin ```var people = [{id:1,name: 'bob',children: [{name: 'george',mother: 'victoria',country:'usa',},{name: 'tyler',mother: 'jamie',country: 'canada'}]}];

// api call something like this
// api/people?include=children[country=usa]
var response1 = [{id:1,name: 'bob',children: [{name: 'george',mother: 'victoria',country:'usa',}]}];

// then we run the same query but different country say mexico
var response2 = [{id:1,name: 'bob',children: []}];

// store still has response1 and gives us that object instead.```

Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:18
This can be solved by attaching a set algebra to the connection @Xitstrategies
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 19:19
not a whole lot of documentation on how to do a set algebra for filtering our subobject lists
any help/suggestions would be great.
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:20
That's true, but I mean that instead of removing the constructor store behavior, you can set it up to have no id
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 19:20
?
Frank Lemanschik
@frank-dspeed
Apr 26 2017 19:20
@bmomberger-bitovi thanks so it is so complicated that droping the loader helps a lot to get a prototype more fast done :)
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:22
@Xitstrategies Everything in an instance store is keyed on the ID property, which is specified when you set up the connection -- previously it was its own property on the connection, i.e. http://canjs.com/doc/can-connect/base/base.idProp.html
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 19:23
right
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:24
With set algebra you can set up more complex IDs (spanning multiple keys), or none at all. http://canjs.com/doc/can-set.Algebra.prototype.id.html
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 19:25
so you think if I remove the id it would not put it in the store?
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:30
Yes. If your identifying set is always null it will not add references to the store.
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 19:33
what about saving?
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:39
Probably no effect if you're not using real-time, but this is such an edge case that I can't state authoritatively what will happen
Morgan Heimbeck
@Xitstrategies
Apr 26 2017 19:40
I am about to try it out. I'll let you know.
Brad Momberger
@bmomberger-bitovi
Apr 26 2017 19:42
@frank-dspeed I still recommend working with the loader because it keeps things a lot more modular. If you need the same stuff on the console repeatedly, you can stick them on the window in your code while developing, or make a debugging module that exports a bunch of stuff to the window, and use System.import from the console to import that instead.
Eben
@eben-roux
Apr 26 2017 20:01
hello
I am trying to use can-validate-validatejs
to validate a can-define/map would I need to serialize it?
Eben
@eben-roux
Apr 26 2017 20:05
pffft... how did I miss that? I'll have a look, thanks Kevin
Kevin Phillips
@phillipskevin
Apr 26 2017 20:06
not sure. if I remember anything from high school, the longest answer is usually correct… and can-define-validate-validatejs is definitely longest.
Eben
@eben-roux
Apr 26 2017 20:06
lol
blob
ok, so I get that as a validation result
Eben
@eben-roux
Apr 26 2017 20:11
however, according the documentation it should rather be something like this:
blob
Kevin Phillips
@phillipskevin
Apr 26 2017 20:15
looks like the documentation needs to be updated
Eben
@eben-roux
Apr 26 2017 20:15
so instead of, as documented, an array of objects with the [{property: [errors]}] I get an array of errors with a related property: `[{message: '.... ok, so I'm not typing anymore
:)
ah, thanks
Must admit that it seems a bit odd. What I see in the docs seems more intuitive.
Kevin Phillips
@phillipskevin
Apr 26 2017 20:16
the docs for errors() are correct
Eben
@eben-roux
Apr 26 2017 20:17
almost seems as though each error message would have an array of failed property names... but there seems to be a 1-to-1 relationship
Kevin Phillips
@phillipskevin
Apr 26 2017 20:18
yeah, I’m not sure why it’s formatted like that
perhaps @Macrofig is around and could explain
Eben
@eben-roux
Apr 26 2017 20:23
If I have <sentinel-text focus="true" label="user:username" {(value)}="username" /> is there a way to get the attribute name username that is bound to {(value)}?