rsvp-promise

Do I always need catch() at the end even if I use a reject callback in all then-ables?

前提是你 提交于 2019-12-29 09:58:21
问题 I am putting catches at the end, but they are returning empty object in one particular instance at least. Is a catch necessary for anything unbeknownst, or is it just screwing me up? $( document).ready(function(){ app.callAPI()//a chainable a RSVP wrapper around a jquery call, with its own success() fail() passing forward to the wrapper, so it will either be a resolved or rejected thenable to which is now going to be chained .then( function(env) { //set the property you needed now app

How to read multiple files asynchronously with promises, then proceed

喜欢而已 提交于 2019-12-21 04:55:23
问题 I'm new to promises and using the rsvp implementation. I want to asynchronously read a list of files, then proceed to another task only when all files have been read. I've got as far as the basic structure to read one file, and chain to the next task: var loadFile = function (path) { return new rsvp.Promise(function (resolve, reject) { fs.readFile (path, 'utf8', function (error, data) { if (error) { reject(error); } resolve(data); }); }); }; loadFile('src/index.txt').then(function (data) {

How to return a promise composed of nested models in EmberJS with EmberData?

不羁岁月 提交于 2019-12-18 12:30:15
问题 Enviroment # Ember : 1.4.0 # Ember Data : 1.0.0-beta.7+canary.b45e23ba Model I have simplified my use case to make the question easier to understand and anwser. Let's assume we have 3 models: Country , Region and Area : Country: - id: DS.attr('number') - name: DS.attr('string') - regions: DS.hasMany('region') Region: - id: DS.attr('number') - name: DS.attr('string') - country: DS.belongsTo('country') - areas: DS.hasMany('area') Area: - id: DS.attr('number') - name: DS.attr('string') - region:

How do Promises/A+ implementations vary?

不打扰是莪最后的温柔 提交于 2019-12-18 07:41:07
问题 What aspects of a promise library does the spec not cover? What kind of things vary between implementations? Please illustrate with examples of actual differences (eg between Bluebird and Q). 回答1: Almost everything. The Promises/A+ spec is aimed for promise interoperability, it's built so promise libraries (and now, native promises) can talk to each other . The idea is for it to be possible to predict how a promise behaves and to define how promises are assimilated by other libraries. Quoting

EmberJS “this” changed in promise (find) callback

自古美人都是妖i 提交于 2019-12-13 19:13:23
问题 When I want to fetch an account from the server in an controller action e.g: account: false, actions: { // When the oAuth popup returns this method will be called fetchUser: function(id) { // Get the account from the server this.store.find('account', id).then(function(account) { this.set('account', account); }, function(error) { console.log('error', error); }); }, } It throws an error because "this" on the line this.set('account', account) is no longer the controller. How can I set "account"

Angular POS Print Issue

别等时光非礼了梦想. 提交于 2019-12-11 11:37:18
问题 My requirement: Print without print preview angular 6 Only solution i found Angular 2 Raw Printing Service I am using think link for Angular POS print Do i have any other alternatives? .ts code printInvoice() { console.log(this.printService.getPrinters()); } My Service code import { Observable } from 'rxjs'; import 'rxjs/add/observable/fromPromise'; import 'rxjs/add/observable/throw'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; import { Injectable } from '@angular/core';

How to read multiple files asynchronously with promises, then proceed

你离开我真会死。 提交于 2019-12-03 15:09:35
I'm new to promises and using the rsvp implementation. I want to asynchronously read a list of files, then proceed to another task only when all files have been read. I've got as far as the basic structure to read one file, and chain to the next task: var loadFile = function (path) { return new rsvp.Promise(function (resolve, reject) { fs.readFile (path, 'utf8', function (error, data) { if (error) { reject(error); } resolve(data); }); }); }; loadFile('src/index.txt').then(function (data) { console.log(data); return nextTask(data); }).then(function (output) { //do something with output }).catch

How to return a promise composed of nested models in EmberJS with EmberData?

安稳与你 提交于 2019-11-30 07:14:32
Enviroment # Ember : 1.4.0 # Ember Data : 1.0.0-beta.7+canary.b45e23ba Model I have simplified my use case to make the question easier to understand and anwser. Let's assume we have 3 models: Country , Region and Area : Country: - id: DS.attr('number') - name: DS.attr('string') - regions: DS.hasMany('region') Region: - id: DS.attr('number') - name: DS.attr('string') - country: DS.belongsTo('country') - areas: DS.hasMany('area') Area: - id: DS.attr('number') - name: DS.attr('string') - region: DS.belongsTo('region') Expected results The Route's model hook should return an array of objects. Like

Do I always need catch() at the end even if I use a reject callback in all then-ables?

余生颓废 提交于 2019-11-29 18:37:21
I am putting catches at the end, but they are returning empty object in one particular instance at least. Is a catch necessary for anything unbeknownst, or is it just screwing me up? $( document).ready(function(){ app.callAPI()//a chainable a RSVP wrapper around a jquery call, with its own success() fail() passing forward to the wrapper, so it will either be a resolved or rejected thenable to which is now going to be chained .then( function(env) { //set the property you needed now app.someSpecialEnvObj = env; }, function(rejectMessage){ console.log('call.API() cant set some special env object.