greenkeeper[bot] on core-js-3.4.8
chore(package): update core-js … (compare)
cherifGsoul on update-infrastructure-page
Update infrastructure page with… (compare)
greenkeeper[bot] on @feathersjs
chore(package): update @feather… (compare)
greenkeeper[bot] on @feathersjs
chore(package): update @feather… (compare)
greenkeeper[bot] on core-js-3.4.7
chore(package): update core-js … (compare)
greenkeeper[bot] on core-js-3.4.6
chore(package): update core-js … (compare)
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
.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.
Guys correct me if I'm wrong. I need to add items to the list, and on UI it should appear at the top of the list (currently it adds to bottom and this is expected).
I'm using real-time
behavior so can.js
understands when to add by itself:
save() {
this.entity.save((entity) => {
Entity.connection.createInstance(entity);
});
},
What the correct way to tell it to add to very top of the list ? custom sort function in component when my list changes ?
There is also https://canjs.com/doc/can-set.props.sort.html but not sure that my case is correct for this, because as I got this designed to understand where we need to insert item, but I know this.
I just based my solution on this example:
https://canjs.com/doc/can-connect/real-time/real-time.createInstance.html
as I got we have to call this createInstance
right after our connection
saved the instance. In my case this is not socket.io
but normal ajax
call based on url
behavior.
or even if this is not a distributed system you should maybe trigger it from a event emitter i think
not sure that I understand the way how this should be organized.
did you know that a canDefineMap is a eventEmitter?
I know that we can call something like map.dispatch('customEvent', [data])
, but not sure that I understand how this should improve the case.
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.
entity adder
component will update list in another component, because it knows nothing about it. It just makes POST
request using connection