Expose Spine.Promise as a replaceable Promise factory.

A default jQueryPromise implementation is provided, which returns a jQuery.Promise object. Because the Promises/A+ spec defines a Promise as "an object with a 'then' property which is a function", developers are encouraged to interact with a Spine.Promise in a standards-compliant fashion, e.g., only interact with the 'then' method of the Promise. Developers wishing to take advantage of more feature-rich Promise implementations should explicitly define their own Promise factory implementation for Spine.

The Promise implementation used by Spine can easily be configured by providing an alternative implementation. For example, following is a Spine.Promise factory which creates native ES6 Promise object:

Spine.Promise = class NativePromise
  @resolve: (result) -> Promise.resolve(result)
  @reject: (error) -> Promise.reject(error)
  constructor: (fn) -> new Promise(fn)

The implementation should provide a constructor that receives a 'resolver' function. The resolver should invoke either 'resolve' with a result or 'reject' with an error to satisfy the Promise. The resolver function should take the following form:

resolver = (resolve, reject) -> # do async work

Similarly, an implementation for the Q library might go something like this:

Spine.Promise = class QPromise
  @resolve: (result) -> Q(result)
  @reject: (error) -> Q.reject(error)
  constructor: (fn) -> Q.Promise(fn)