Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:58
    greenkeeper[bot] commented #5372
  • 14:58

    greenkeeper[bot] on can-observable-mixin-1.0.2

    fix(package): update can-observ… (compare)

  • 14:49
    greenkeeper[bot] labeled #5379
  • 14:49
    greenkeeper[bot] opened #5379
  • 14:49

    greenkeeper[bot] on can-dom-mutate-2.0.6

    fix(package): update can-dom-mu… (compare)

  • 14:06

    greenkeeper[bot] on webpack-4.41.2

    (compare)

  • 13:37

    greenkeeper[bot] on webpack-4.41.2

    chore(package): update webpack … (compare)

  • Oct 14 21:13
    greenkeeper[bot] labeled #5378
  • Oct 14 21:12
    greenkeeper[bot] opened #5378
  • Oct 14 21:12

    greenkeeper[bot] on can-simple-map-4.3.3

    fix(package): update can-simple… (compare)

  • Oct 14 20:19
    greenkeeper[bot] labeled #5377
  • Oct 14 20:19
    greenkeeper[bot] opened #5377
  • Oct 14 20:19

    greenkeeper[bot] on @feathersjs

    chore(package): update @feather… (compare)

  • Oct 14 20:18
    greenkeeper[bot] labeled #5376
  • Oct 14 20:18
    greenkeeper[bot] opened #5376
  • Oct 14 20:18

    greenkeeper[bot] on @feathersjs

    chore(package): update @feather… (compare)

  • Oct 14 14:43
    greenkeeper[bot] closed #5373
  • Oct 14 14:43

    greenkeeper[bot] on can-deep-observable-1.0.1

    (compare)

  • Oct 14 14:42

    m-mujica on update-deep-observable

    (compare)

  • Oct 14 14:42

    m-mujica on master

    Update can-deep-observable to l… Merge pull request #5374 from c… (compare)

Frank Lemanschik
@frank-dspeed
its for getting called external
Viktor Busko
@Lighttree
Mmmm this updates UI on the fly :)
so I just make save and UI updates with the new item in the list )
Frank Lemanschik
@frank-dspeed
your case looks more like return new Entity(entity)
is what you want
it sounds like you designed something wrong :)
ah UI updates
i understand the normal way for this is diffrent i think but overall when it works let it work
but in general the ui should simply update when a value changes
because defineMaps are event emitters that dispatch events
create instance is a bridge
when a creation happens outside the ViewModel of the object
for example if you write a function that polls a server for changes
it can call this to add instances from server
but its not needed if your work in your frontend only
Viktor Busko
@Lighttree

MMmmm ok I'll try to clarify the case, because I showed you just one function :)

I have 1 component that renders list of entitiy
I have another component that adds new items in this list. But this is separate component, so I have to make "something" to update the list in another component.
And real-time with createInstance do the work :) Well...not sure that this is correct way.

I had no expectations that entity adder component will update list in another component, because it knows nothing about it. It just makes POST request using connection
But maybe I'm missing something...not sure
Frank Lemanschik
@frank-dspeed
Entity Model
should have Entity.list
a instance store most time made via canDefineList
so when ever you create a Entity with some values it adds that instance to its Enitity.list i think
:D
i think this is used in all guides look at it
Viktor Busko
@Lighttree

yes I have entity model like this:

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 realTime from 'can-connect/real-time/real-time';
import constructor from 'can-connect/constructor/constructor';
import constructorStore from 'can-connect/constructor/store/store';
import canMap from 'can-connect/can/map/map';
import memoryCache from 'can-connect/data/memory-cache/memory-cache';
import authBehavior from './authBehavior';
import Person from './person.model';
import fallThroughCache from './fall-through-cache-custom';

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

const entity = DefineMap.extend({
    activityType: 'string',
    clientId: 'number',
    id: 'number',
    creatorId: 'number',
    message: 'string',
    created: 'number',
    managerId: 'number',
    employeeId: 'number',
    externalId: 'number',
    readEmployee: 'boolean',
    readManager: 'boolean',
    title: 'string'

});

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

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

entity.connection = connect(
    [realTime, authBehavior, parse, fallThroughCache, constructor, constructorStore, canMap], {
        url: 'v1/entity',
        Map: entity,
        List: entity.List,
        name: 'entity',
        parseListData(response) {
            return { data: response };
        },
        parseInstanceData(responseData) {
            return responseData.entityVO;
        },
        algebra,
        cacheConnection
    });

export default entity;

But it didn't refreshed UI untill I refresh the page.. so I was thinking that real-time is something that I have to use. But now I'm confused and not sure :D

Frank Lemanschik
@frank-dspeed
there it is List
no the list gets updated by getter and setter most time
you bind a value in stache to a getter setter
and when ever something changes
this will get updated on the screen
so DefineMap is simply a eventEmitter
and emits events on get and set to stache
:D
hope that makes sense
for example you can make a value that returns a setInterval that sets a value on the viewModel like this.myVal = 2+x
then this will get reflected if you bind myVal
in stache
this way you can make nice count downs by the way
:D
Frank Lemanschik
@frank-dspeed
so remember your view should always get updated via the viewModel it self without a connection
the connection is only to add stuff from outside like a server or other eventEmitter
so if you use 2 diffrent models 2x defineMap for example
you can simply set model 1 as property of value 2
no need for a extra function
Viktor Busko
@Lighttree

Well I know this that you can bind and observable values will be updated etc...

The problem that when you send data to the sever it didn't updated the list with new data (and UI obviously) without some additional logic . Maybe I missed something here:

import Component from 'can-component';
import DefineMap from 'can-define/map/map';
import enitty from './../../models/enitty.model';
import view from './enitty-list.stache';
import './enitty-list.scss';
import './enitty.svg';
import './checkin-card';

export const ViewModel = DefineMap.extend({
    owner: '*',
    currentPersonPromise: '*',
    enittyListPromise: {
        get() {
            return enitty.getList({
                employeeId: this.owner.id
            });
        }
    },
    enittyList: {
        Type: [enitty],
        get(lastSet, resolve) {
            this.enittyListPromise.then(resolve);
        }
    },
    isCurrentUserOwner: 'boolean'
});

export default Component.extend({
    tag: 'gf-enitty-list',
    ViewModel
});

But with real-time it works at least :)

Frank Lemanschik
@frank-dspeed
it looks good for me and i understand your problem
it don't updates because its not informed that the server updates
and the new value gets set no where on the viewModel
Viktor Busko
@Lighttree

it don't updates because its not informed that the server updates
and the new value gets set no where on the viewModel

Not sure... is this normal behavior or I'm doing wrong ? )

Frank Lemanschik
@frank-dspeed