javascript - bluebird - promise chain return unexpected "true" value -


I am writing an app using ReactJs so I wrote 2 simple node.js-modules . For the first time brings an XML API and gives an array of objects, the second is a simple datastore, which should save the received dataset. Both modules use async use bluebird .

Now I have the following scenario:

  var promise = requirement ('Bluebird'); Store.get () Tap (print) // # 1: []. Then (function (data) {if (data.length) {return promise.resolve (data); // # 6:? Is also true second run?} Else {return xmlApi.get (). Tap (print) / / # 2: [...] .then (store.insert) // - It returns an array with the inserted index.Tap (print) // # 3: [...] -then (store .write) // - It gives all the stored objects as an array.Tap (print) // # 4: True & lt; -? This is what I do not understand ... ?}}) Tap (print) // # 5: true Then (work (data) {// under normal circumstances, I will set the ReactJs state from the data array ...}). Hold (handleError) .done ();  

My problem is to understand why # 3 sort out arrays with all right instead of values Does ? While testing the libraries in the pure node, everything is fine. But in the second part, when the data is stored in the store, the promise true ...

update:

< Code> store.write

  var write = promise.promisify (Required ('FS'). WriteFile) Store.prototype.write = function () {return write (This. Filename, JSON.stringify (this.data)) .bind (this) .then (function () {Promise.resolve (this.data);}); };  


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -