Promises and dragStart


I want to set data on dragstart. The data is retrieved via promises. I’m thinking I could either set the data like this.

dragStart: (ev)->
  myPromise.then (data)=>
    ev.dataTransfer.setData’(application/json’, data)

or something like this

dragStart: (ev)->
  App.DragPromises.set(random_key, myPromise)
  ev.dataTransfer.setData’(text/plain’, random_key)

drop: (ev)->
  key = ev.dataTransfer.getData("text/plain")
  myPromise = App.DragPromises.get(key)

  myPromise.then (data)->

I’m thinking option 1 might cause problems if the promise isn’t fulfilled when the drop occurs. Option 2 doesn’t encapsulate the data as well, it relies on the application global DragPromises