DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
      • behaviors
        • ./base/
        • ./cache-requests/
        • ./can/map/
        • ./can/ref/
        • ./constructor/callbacks-once/
        • ./constructor/
        • ./constructor/store/
        • ./data/callbacks/
        • ./data/callbacks-cache/
        • ./data/combine-requests/
        • ./data/localstorage-cache/
        • ./data/memory-cache/
        • ./data/parse/
        • ./data/url/
        • ./data/worker/
        • ./fall-through-cache/
        • ./real-time/
          • methods
            • createInstance
            • destroyInstance
            • updateInstance
          • data callbacks
            • createdData
            • destroyedData
            • updatedData
      • modules
        • ./can/base-map/
        • ./can/model/
        • ./can/super-map/
        • ./can/tag/
        • ./helpers/weak-reference-map
      • data types
        • DataInterface
        • Instance
        • InstanceInterface
        • List
        • ListData
    • can-define
    • can-define/list/list
    • can-define/map/map
    • can-route
    • can-route-pushstate
    • can-set
    • can-stache
    • can-stache/helpers/route
    • can-stache-bindings
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-connect
  • /
  • ./real-time/
  • /
  • createInstance
  • / On this page
    • createInstance

      function

      Programatically indicate a new instance has been created.

      • source

      connection.createInstance(props)

      If there is no instance in the instanceStore for props's id, an instance is hydrated, added to the store, and then createdData is called with props and the hydrated instance's serialized data. createdData will add this instance to any lists the instance belongs to.

      If this instance has already been created, calls updateInstance with props.

      Parameters

      1. props {Object}:

      Returns

      {Promise<Instance>}:

      Use

      With a real-time connection, call createInstance when an instance is created that the connection itself did not make. For instance, the following might listen to socket.io for when a todo is created and update the connection accordingly:

      socket.on('todo created', function(todo){
        todoConnection.createInstance(order);
      });
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.