These are chat archives for canjs/canjs

5th
Jul 2018
Jeroen Cornelissen
@jeroencornelissen
Jul 05 2018 08:09
@qantourisc you want to set a read-only var? You could use a static property on your DefineMap and return that in a get.
Something like this:
var MyMap = can.DefineMap.extend('MyMap', {
  staticProp: 'iamstatic'
}, {
  get prop() {
   return MyMap.staticProp; 
  }
})
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:11
and never forget there is also symbols they are also made for such use cases and also javascript proxys
qantourisc
@qantourisc
Jul 05 2018 08:23
@jeroencornelissen It still needs to update via internal functions ;) but thatnks
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:23
@qantourisc google javascript proxys
qantourisc
@qantourisc
Jul 05 2018 08:23
@canJS-Devs: can-connect caching stuff needs some guide on how to use it, when the cache updates etc. It doesn't behave as i'd expect.
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:24
can connect has no caching stuff but there are some behaviers
that can be used with it to add that
qantourisc
@qantourisc
Jul 05 2018 08:24
Sorry I mean the mixins used with base-map and super-map
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:24
base map uses caching hmm could be
but i think this will get more easy soon
Jeroen Cornelissen
@jeroencornelissen
Jul 05 2018 08:25
super-map uses caching, not base-map
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:25
as also more clear soon with the new canjs 5 and can query
@jeroencornelissen thanks for pointing that out as far as i remember your right
supermap is a version using all behaviors
qantourisc
@qantourisc
Jul 05 2018 08:26
Let me add all behaviours again and see which one is getting me confused
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:27
good idea do so
maybe we can help you to adjust it
or write your own
its designed the way it is so a user can finetune the behaviors and add custom once
qantourisc
@qantourisc
Jul 05 2018 08:27
CanJS'ses probably works great, just how it handles stuff exactly, is probably it
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:28
it handels out of the box a high percent rate of use cases and can handle anything
thats how its designed
you should have no blocking issues like it handels stuff wrong or none expected as soon as you know what you want to do i am sure we can get that up and running
qantourisc
@qantourisc
Jul 05 2018 08:30
constructor/callbacks-once <= If I edit an object, then getListData again, the object is not refreshed.
Note: object is still dirty
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:31
hmmm for me this sounds a bit confusing
a constructor should not edit a object
qantourisc
@qantourisc
Jul 05 2018 08:31
Did I explain it poorly ?
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:32
you explained it right but a code example would still help
qantourisc
@qantourisc
Jul 05 2018 08:32
hmmm, let me try
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:34
something as small as possible
demonstrating what it does and what you expect it to do
qantourisc
@qantourisc
Jul 05 2018 08:35
Then I need some mockup storage with that ....
actually I could do that
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:35
can-fixture?
is the mockup storage?
qantourisc
@qantourisc
Jul 05 2018 08:35
just return [{}] ?
Cause there might also be an issue there ;)
Frank Lemanschik
@frank-dspeed
Jul 05 2018 08:36
maybe you should start first then at the backend
and simply verify what it returns when
and then do the frontend stuff
else you will need more time
qantourisc
@qantourisc
Jul 05 2018 09:03
https://jsbin.com/bujihanune/1/edit?html,console <= this code had the bug, cannot reproduce atm :/
Not even in production
qantourisc
@qantourisc
Jul 05 2018 11:50
hmm native Promise objects are a tad icky: if you fail to throw at the end of a catch, you suddenly end up in .then space.
qantourisc
@qantourisc
Jul 05 2018 12:47
I wrapped it in some thing that handles it. Bonus: when the promise is updated before it's done, the old actions are removed.
qantourisc
@qantourisc
Jul 05 2018 12:54
can-define/map/map.prototype.set is deprecated; please use can-define/map/map.prototype.assign or can-define/map/map.prototype.update instead
OK : can.DefineMap.prototype.set = undefined;
TypeError: this.set is not a function[Learn More] can.all.js:15119:13 haha :D
Justin Meyer
@justinbmeyer
Jul 05 2018 16:09
image.png
I'm struggling to come up with a title for "service data" ... Should it be:
  1. Models
  2. Data layer
  3. Service layer
  4. Backend services
  5. Backend data
Julian
@pYr0x
Jul 05 2018 16:21
is there a way to store the current state and working with Hot Module Swapping
currently i have in my package.json "main": "medicalpad/index.stache!done-autorender/no-zone",
after i turned on HMR
<script src="node_modules/steal/steal-sans-promises.js">
    import reload from "live-reload";
    reload(function(){
      console.log("Hot Module Swapping");
    });
  </script>
it works, but the current state get lost
in my index.stache i have <can-import from="~/app" export-as="viewModel"/> and the viewModel gets replaced very time
@justinbmeyer i prefer Models or Service Layer
Justin Meyer
@justinbmeyer
Jul 05 2018 16:27
so in a donejs app ... your state is typically saved by can-route and re-applied
you could setup live-reload to basically do something similar
@matthewp would know more than me about how to do it w/ live-reload
but essentially, I would serialize my app VM before the live-reload, and then apply it after
qantourisc
@qantourisc
Jul 05 2018 16:42
@justinbmeyer How would you desribe it ? Or is it online ?
Maybe just data retrieval ;)
Justin Meyer
@justinbmeyer
Jul 05 2018 17:40
I think I'm going with service layer.
data retrieval sounds like only "getting" data ... where we talk about manipulating it too
Julian
@pYr0x
Jul 05 2018 18:21
@matthew do you have an idea how i can store my appState during live-reload
Justin Meyer
@justinbmeyer
Jul 05 2018 18:21
do you know where other frameworks store it?
just on the window?
Julian
@pYr0x
Jul 05 2018 18:22
the problem is, that live-reload do some stuff in "done-autorender"
Justin Meyer
@justinbmeyer
Jul 05 2018 18:22
ah
well, that shouldn't really matter
i stored it on my window object
Justin Meyer
@justinbmeyer
Jul 05 2018 18:22
so the init of your APP VM
or maybe even the setup() method
Julian
@pYr0x
Jul 05 2018 18:22
yes
Justin Meyer
@justinbmeyer
Jul 05 2018 18:22
you could read from the window object
and set any new values you want
Julian
@pYr0x
Jul 05 2018 18:23
const AppViewModel = DefineMap.extend({
  init: function () {
    console.log("init");

    if(!window.appState){
      window.appState = this;
    }
    // readCookie();

    // this.bind(this.lang, function () {});
  },
import reload from "live-reload";
    import canViewModel from "can-view-model";
    import route from "can-route";
    import canReflect from "can-reflect";
    import canSymbol from "can-symbol";

    window.canViewModel = canViewModel;

    reload(function(){
      route.stop();
      var session = window.appState.session;

      canReflect.setKeyValue(document.documentElement, canSymbol.for("can.viewModel"), window.appState);

      route.data = window.appState;
      // route.register("{page}", {page: "login"});
      // route.register("dashboard/{dashboard}", {dashboard: "logistics"});
      route.start();

      route.data.dashboard = "medical";

      // domData.set( document.documentElement, "viewModel", window.appState);
      // var vm = canViewModel(document.documentElement);

      // canViewModel(window.appState);

      console.log();
      console.log("Hot Module Swapping");
    });
Justin Meyer
@justinbmeyer
Jul 05 2018 18:23
hmm, I'm not sure about this
Julian
@pYr0x
Jul 05 2018 18:23
but this reload is running after the reload from auto-autorender
Justin Meyer
@justinbmeyer
Jul 05 2018 18:23
I don't think you can keep the actual VM instance around
you need the serialized data
and then to update the newly created VM with the last serialized data
Julian
@pYr0x
Jul 05 2018 18:24
yeah but the session object is serialize=false
Justin Meyer
@justinbmeyer
Jul 05 2018 18:24
yeah, this is why we are trying to move people to have the routing data in a "child object" w/i their appVM
I mean, for now, you could just include it in what you serialize
var lastState = appVM.serialize();
lastState.session = appVM.session.serialize()
Julian
@pYr0x
Jul 05 2018 18:25
and how can i apply it to the new VM created by done-autorender after reload?
Justin Meyer
@justinbmeyer
Jul 05 2018 18:26
in the setup() method
setup(props){
  Object.assign(props || {}, lastState)
  return this._super( props )
}
something like that probably
Julian
@pYr0x
Jul 05 2018 18:27
ok i will check that
thx
Justin Meyer
@justinbmeyer
Jul 05 2018 18:28
(you could do it in init() also ... but at that point you are changing values instead of being initialize do them
Julian
@pYr0x
Jul 05 2018 18:33
you said, that i should move routing into a child object in my VM
but done-autorender does all the stuff
Justin Meyer
@justinbmeyer
Jul 05 2018 18:33
yeah, that's true
Justin Meyer
@justinbmeyer
Jul 05 2018 18:34
I think we've talked about ways of providing a key so you can say attach routing to viewModel.routeData sorta thing
Julian
@pYr0x
Jul 05 2018 18:35
ah ok
but for now simply putting session to serialize = true solve all my state problems
Justin Meyer
@justinbmeyer
Jul 05 2018 18:36
will it?
Julian
@pYr0x
Jul 05 2018 18:36
but i have to remove it before pushing to prod
yeah i will, i think the connection between route.data and viewmodel
it will copy the serialized string into route-data and viewmodel
Justin Meyer
@justinbmeyer
Jul 05 2018 18:39
I don't think it will because you'll get the session added to the url
Julian
@pYr0x
Jul 05 2018 18:41
i removed all my code
just serialized session to true
qantourisc
@qantourisc
Jul 05 2018 18:57
@justinbmeyer Data Service Layer ? i'd personally noy connect Service to data :D
Justin Meyer
@justinbmeyer
Jul 05 2018 19:50
asked the question w/i bitovi
image.png
Justin Meyer
@justinbmeyer
Jul 05 2018 21:10
WOAH
codepen embeds it in the page
qantourisc
@qantourisc
Jul 05 2018 21:47
How do i do <input list="{{some-id"}}/> ? in stache, it seems to want to bind to viewModel.list instead of el.list ?
qantourisc
@qantourisc
Jul 05 2018 23:37
Hmmm it's actually the browser complaining about the fact you cannot do el["list"]="value; el being an INPUT
aurelia/framework#646
yep
qantourisc
@qantourisc
Jul 05 2018 23:44
Is there a way to do this in stache ?