How to use the can-connect/can/super-map/ function in can-connect

To help you get started, we’ve selected a few can-connect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github donejs / donejs / guides / place-my-order / steps / create-test / restaurants_model.js View on Github external
seal: false
}, {
  '_id': '*'
});

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

const algebra = new set.Algebra(
  set.props.id('_id'),
  set.props.dotNotation('address.state'),
  set.props.dotNotation('address.city')
);

Restaurant.connection = superMap({
  url: loader.serviceBaseURL + '/api/restaurants',
  Map: Restaurant,
  List: Restaurant.List,
  name: 'restaurant',
  algebra
});

export default Restaurant;
github marshallswain / AmityApp / public / src / models / server.js View on Github external
import can from 'can';
import superMap from 'can-connect/can/super-map/';
import tag from 'can-connect/can/tag/';
import 'can/map/define/define';
import io from 'steal-socket.io';
const socket = io();

export const Server = can.Map.extend({
  define: {}
});

Server.List = can.List.extend({
  Map: Server
}, {});

export const serverConnection = superMap({
  url: '/amity/servers',
  idProp: 'name',
  Map: Server,
  List: Server.List,
  name: 'server'
});

tag('server-model', serverConnection);

socket.on('servers created', server => serverConnection.createInstance(server));
socket.on('servers updated', server => serverConnection.updateInstance(server));
socket.on('servers removed', server => serverConnection.destroyInstance(server));

console.log(serverConnection.getList);

export default Server;