Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 04 22:03
    chasenlehara opened #5440
  • Dec 04 22:03
    chasenlehara labeled #5440
  • Dec 04 19:18
    cherifGsoul review_requested #5432
  • Dec 04 14:09
    m-ahmadi starred canjs/canjs
  • Dec 04 10:52
    ansyeow starred canjs/canjs
  • Dec 03 14:53
    matthewp commented #5439
  • Dec 03 14:30
    frank-dspeed opened #5439
  • Dec 02 18:13
    greenkeeper[bot] commented #5392
  • Dec 02 18:13

    greenkeeper[bot] on core-js-3.4.7

    chore(package): update core-js … (compare)

  • Dec 02 17:48
    greenkeeper[bot] commented #5392
  • Dec 02 17:48

    greenkeeper[bot] on core-js-3.4.6

    chore(package): update core-js … (compare)

  • Dec 02 15:38
    phillipskevin commented #5438
  • Dec 02 15:38
    phillipskevin closed #5438
  • Dec 02 15:38
    phillipskevin commented #5438
  • Dec 01 23:28
    justinbmeyer commented #5438
  • Dec 01 23:06
    justinbmeyer commented #5438
  • Dec 01 23:06
    justinbmeyer commented #5438
  • Dec 01 23:04
    justinbmeyer edited #5438
  • Dec 01 23:03
    justinbmeyer opened #5438
  • Nov 29 15:01
    cherifGsoul synchronize #5432
Kevin Phillips
@phillipskevin
ok
Michael Price
@web-mech
gotcha
Kevin Phillips
@phillipskevin
and you want to be able to call set with an object so you can set multiple properties
instead of using splice or something on the list itsself
Gregg Roemhildt
@roemhildtg
Yes, that's right
Kevin Phillips
@phillipskevin
ok
Gregg Roemhildt
@roemhildtg
the form object's properties can be strings, ints, etc, in one case I have it set to a list so I can have a list of items, like checkboxes
But that list is one field
so if that field changes, it gets added to the dirty object to be validated, then submitted
for now, I can just iterate the fields, and update the props one by one. But set would be nicer
I think that map.set({ prop: [] }); and map.prop = [] should do the same thing, right?
Kevin Phillips
@phillipskevin
in this case, they probably should do the same thing
but it obviously has to go through different code paths
in case you have something like map.set({ foo: { bar: { baz: [] } } })
Gregg Roemhildt
@roemhildtg
right, that makes sense
I can see the benefit to deep assigning objects, thats clear but when would you want to deep assign array?
Viktor Busko
@Lighttree
Guys is there concept of root scope in can.js ? Something that can be accessible from any level ? I have to pass synthetic param like "current user" or "current language" to many components, and it feels like this should work something like globalScope.currentUser. I know that I can share it by setting leakScope but this will share scope implicitly.
Paul Tichonczuk
@tracer99
Our APIs suck. So even when we have an error, the response code is 200. How do we extend a basemap to check for the contents of an ajax response and throw the flow into the error state?
I think I have found my answer... trying
  url: {
    getListData: 'GET /json/shop/devices',
    getData: () => {

    }
  },
Paul Tichonczuk
@tracer99
still don't know how to route to failure though
Paul Tichonczuk
@tracer99
wrap the whole thing in a promise. doh. ok. it was nice talking to myself.
(Just need a cardboard cutout of Kevin here to talk to )
Frank Lemanschik
@frank-dspeed
np
Kevin Phillips
@phillipskevin
maybe I'll start selling those :smile:
Paul Tichonczuk
@tracer99
@phillipskevin Bitovi obviously needs a store to sell that and other useful items :)
Viktor Busko
@Lighttree

Hi guys, I have one question regarding can-connect. I have following model:

import DefineMap from 'can-define/map/map';
import DefineList from 'can-define/list/list';
import set from 'can-set';
import connect from 'can-connect';
import parse from 'can-connect/data/parse/parse';
import constructor from 'can-connect/constructor/constructor';
import canMap from 'can-connect/can/map/map';
import fallThroughCache from 'can-connect/fall-through-cache/fall-through-cache';
import constructorStore from 'can-connect/constructor/store/store';
import memoryCache from 'can-connect/data/localstorage-cache/localstorage-cache';
import realTime from 'can-connect/real-time/real-time';
import authBehavior from './authBehavior';

// Connection behaviors list
const behaviors = [realTime, authBehavior, fallThroughCache, constructorStore, parse, constructor, canMap];

const cacheConnection = connect([
    memoryCache
], {
    name: 'entity'
});

const Entity= DefineMap.extend({
    id: 'number',
    creatorId: 'number',
    message: 'string',
    title: 'string',
});

const algebra = new set.Algebra(
    set.props.id('id')
);

Entity.List = DefineList.extend({
    '#': Entity
});

Entity.connection = connect(
    behaviors, {
        url: '/api/v1/entity',
        Map: Entity,
        List: Entity.List,
        name: 'entity',
        parseInstanceData(responseData) {
            return responseData.checkinVO;
        },
        algebra,
        cacheConnection
    });

export default Entity;

I have list of entities on the page:

export const ViewModel = DefineMap.extend({
    entityListPromise: {
        get() {
            return Entity.getList({});
        }
    },
    entityList: {
        Type: [Entity],
        get(lastSet, resolve) {
            this.entityListPromise.then(resolve);
        }
    }
});

I need to add new item to sever and expecting that this list will be updated automatically by:

this.entity.save()

but it seems that it doesn't work :( I can see new item in the list only after page refresh.

I've tried this as well:

this.entity.save().then((response) => {
      Entity.connection.createInstance(response);
});

But didn't succeed as well.
Is it expected that can.js will update list automatically or I have to push this item into list by myself ?

kostya.aderiho
@kaderiho

Hi everyone, could someone help with the next question:

I'm using can.connection with these behaviors: url, constructor, canMap and getting the list of instances using getList():

[{priorityId: 1, description: 'some text'}, {priorityId: 2, description}, ....] .

When I call .save() as a POST request it works fine, but when I try to UPDATE information of this instance my URL is wrong and becomes just like localhost:3000/. As I understood canjs expects to see ID in the list of instance props instead of priorityId.

How I can parse the response of getList() and replace priorityId field on id? Does can.Algebra help with it? Thanks in advance!

kostya.aderiho
@kaderiho

BTW, when I use this algebra:

const algebra = new set.Algebra( set.props.id('priorityId') );

My .get() request looks wrong: localhost:3000/?id=283, but without Algebra it looked fine: https://localhost:3000/priorities/283

Will Stanton
@wstant
Hey everybody, is it possible to test two DefineMaps for equivalency using chai? deep.equal() doesn't seem to be working for me
Kevin Phillips
@phillipskevin
I would .serialize() them first
Will Stanton
@wstant
Hey Kevin!
Thanks, I'll try that out
Will Stanton
@wstant
Still having trouble, any other suggestions?
Kevin Phillips
@phillipskevin
what is the issue?
Will Stanton
@wstant
I'm trying to test a function which updates two properties in route.data- page and flow. The function updates the properties correctly, and if I test the equivalency of each property to the desired value, the test passes
When I try to test the function this way route.data.should.deep.equal(routeTestObject);
I get this assertion error: AssertionError: expected { Object (page, flow) } to deeply equal { Object (page, flow) }
let me know if you'd like to see the code for the test or the function, they're both quite small
Kevin Phillips
@phillipskevin
and you tried route.data.serialize().should.deep.equal(routeTestObject.serialize());?
Will Stanton
@wstant
ah I see, I tried route.data.serialize(); and routeTestObject.serialize(); before the test. It works with .serialize() in the test line
thanks Kevin
Kevin Phillips
@phillipskevin
cool, no problem, Will
Viktor Busko
@Lighttree

Maybe someone have an idea:
I'm trying to dynamically update UI when save something to data base using real-time behavior.
When I use fixture with data and call my list like:

entityListPromise: {
        get() {
            return Entity.getList({});
        }
    },

All works fine and when I save items like:

save() {
        this.entity.save().then((entity) => {
            Entity.connection.createInstance(entity);
            this.close();
        });
    },

UI updates automatically.

But as soon as I disable fixture and do the call with real get params that I need:

entityListPromise: {
        get() {
            return Entity.getList({
                employeeId: this.owner.id,
                startDate: new Date(2017, 1, 1).getTime(),
                endDate: Date.now(),
                limit: 1000
            });
        }
    },

It doesn't work. As I got these params somehow broke this...

Viktor Busko
@Lighttree

The only idea that I had is that the problem in these params:

startDate: new Date(2017, 1, 1).getTime(),
endDate: Date.now(),
limit: 1000

they are not presented in Map that I use.

Gregg Roemhildt
@roemhildtg
Can I pass a property to a define map that I don't want to be serialized?
var obj = new DefineMap({
    myProp: { ....} // I don't want to serialize myProp when I call obj.serialize()
})
Jeroen Cornelissen
@jeroencornelissen
@roemhildtg create a custom Definemap with DefineMap.extend and then setserialize: false on the prop.
Gregg Roemhildt
@roemhildtg
@jeroencornelissen yup, I think that's the only way to do so.
Nico R.
@nriesco

I'm really confused when declaring observables/variables within a defineMap. I think this is probably a basic topic, but I don't know how it really works.

I've seen (so far) the following syntaxes:

export const ViewModel = DefineMap.extend({
  var1: { type: String, value: 'super' },
  var2: { type: 'string', value: 'super' },
  var3: { value: 'hello', serialize: false},
  var4: 'string',
  var5: 'any',
  var6: '*',

})

I don't really know their differences and when to use them. As for the serialize option does it mean that ViewModel.serialize() would return everything except from attributes with serialize: false option?

Thanks

Jeroen Cornelissen
@jeroencornelissen
@nriesco yes, .serialize() doesn’t return serialize: false properties. I see them as “private” properties.
var1 is incorrect and should be Type with a capital T: Type: String or Type: MyCustomMap
var5 & var6 are identical, it means that your var can be anything. If you pass an object to type: ‘*’it stays an object and isn’t converted to a DefineMap.
AntonProkofyev
@AntonProkofyev
Hi all is there any extended guide for algebra?