 class Stacker.Cards extends Backbone.Collection
   model: Stacker.Card
 
-  constructor: ->
+  constructor: (models=[], options={}) ->
     super
     @cid = _.uniqueId('c')
-    @id ||= _.uniqueId('id-')
+    @id ||= options.id || _.uniqueId('id-')
 
   @fromJSON: (data) ->
     cards = Stacker.alloc(this)

    options.history ||= window.history
    options.storage ||= window.sessionStorage
    
    @networkController = Stacker.NetworkController
    @historyStack = Stacker.alloc(Stacker.Cards)
    @historyController = new Stacker.HistoryController(
      @historyStack, options.history, options.storage

window.Stacker = {}

Stacker.Repo = new Backbone.Collection
Stacker.alloc = (klass, args...) -> @Repo.add item = new klass(args...); item
Stacker.get = (id) -> @Repo.get(id)
Stacker.flush = -> @Repo.set [], silent:true

