Skip to content

Releases: canjs/can-connect

Bugfix: constructor/callbacks-once/

08 Feb 23:33
Compare
Choose a tag to compare

#253

The callback-once behavior is to prevent calling the same callbacks multiple times for the same data. E.g. if a new item is created via AJAX, but also WebSocket might receive a "created" event.

The bug was that the behavior didn't consider the method names, e.g. if createdInstance was called for an item then destroyedInstance was not called for the same item.

Maximum call stack if two instances without id are created (can/constructor-hydrate)

15 Mar 16:40
Compare
Choose a tag to compare

can/ref/ref

08 Feb 21:03
Compare
Choose a tag to compare

#248

Set value if its passed for an already existing item in Ref.store

can-connect/can/constructor-hydrate/

26 Jan 22:02
Compare
Choose a tag to compare

#243

The can-connect/can/constructor-hydrate/constructor-hydrate behavior allows to check the connection instanceStore when creating new instances of the connected Map type.

It should be used with can-connect/constructor/store and can-connect/can/map/map behaviors:

var Student = DefineMap.extend({});
Student.List = DefineList.extend({
    '#': { Type: Student }
});

Student.connection = connect([
    require("can-connect/data/url/url"),
    require("can-connect/constructor/constructor"),
    require("can-connect/constructor/store/store"),
    require("can-connect/can/map/map"),
    require("can-connect/can/constructor-hydrate/constructor-hydrate"),
], {
    Map: Student,
    List: Student.List,
    url: "api/students"
});

Now if we try to create two instances with the same id they both will be the same instance:

Student.get({id: 1}).then(function(instance){
    var student = instance;

    var teamLead = new Student({id: 1});

    student === teamLead;
});

can-connect/can/merge/merge

10 Jan 15:26
Compare
Choose a tag to compare

This adds the can-connect/can/merge/merge behavior from #238. Use it to merge can-define with minimal changes and awareness of other connections.

To use make sure your types are configured as follows:

  1. Related types have an .algebra property that is configured with id.
Student = DefineMap.extend({ ... });

Student.algebra = new set.Algebra(set.props.id("_id"))
  1. Related types that have a connection are configured with a .connection property that points to that connection.
Student.connection = baseMap({
    Map: Student,
    List: Student.List,
    url: "/services/students",
    name: "students"
});
  1. Lists of related types use # to point to that type:
Student.List = DefineList.extend({
    "#": Student
});
  1. The base type is configured similar to above, and its connection has canMergeBehavior mixed in as follows:
var canMergeBehavior = require("can-connect/can/merge/merge");
var canMapBehavior = require("can-connect/can/map/map");

var ClassRoom = DefineMap.extend({
    students: Student.List
});

ClassRoom.List = DefineList.extend({
    "#": ClassRoom
});

ClassRoom.algebra = new set.Algebra({...})

ClassRoom.connection = connect([..., canMapBehavior, canMergeBehavior, ...],{
    Map: ClassRoom,
    List: ClassRoom.List
});

Smart Merge

04 Jan 21:22
Compare
Choose a tag to compare

Adds the smart merge helper so it's easier to work with nested structures.

Fix real-time behavior's destroyInstance method

21 Dec 00:11
Compare
Choose a tag to compare

When data passes through the destroyInstance method in the real-time behavior, "destroyed" events will now properly get triggered.

PR: #227

createInstance triggers Map "created" event

19 Dec 22:49
Compare
Choose a tag to compare

Calling createInstance will now trigger the created event on any connected Map constructor.

var Session = DefineMap.extend({
  id: 'any',
  email: 'string'
});

var connection = connect([
  constructor,
  canMap,
  constructorStore,
  dataCallbacks,
  realTime,
  callbacksOnce
], {
  Map: Session
});

Session.on('created', function (event) {
  assert.ok(event, 'createInstance triggered the "created" event');
  done();
});

connection.createInstance({
  id: 5,
  email: '[email protected]'
});

PR: #225

Stop using deprecated can-util methods

14 Dec 18:39
Compare
Choose a tag to compare

#213 - Stop using deprecated can-util methods.

v0.5.5

21 Apr 21:08
Compare
Choose a tag to compare

milestone

Fixes a bug with string based ids.