This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Promise 基于发布订阅的设计模式实现,then方法返回一个新的Promise,状态由上一个promise决定。 | |
*/ | |
Promise.prototype.then=function(onResolved,onRejected){ | |
const self= this | |
return new Promise((resolve,reject)=>{ | |
// 把相同的代码封装起来,并用try catch捕获错误 | |
/* | |
像这种情况,使用者如果抛出错误,直接让下个promise也就是当前返回的promise状态为失败 | |
then(res=>{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
//"bytes" | |
qrcode "github.com/skip2/go-qrcode" | |
"crypto/rand" | |
"fmt" | |
//"image" | |
//"image/png" | |
"os" | |
"runtime" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the Android version of the Tweetie-like pull to refresh table: | |
// http://developer.appcelerator.com/blog/2010/05/how-to-create-a-tweetie-like-pull-to-refresh-table.html | |
var win = Ti.UI.currentWindow; | |
var alertDialog = Titanium.UI.createAlertDialog({ | |
title: 'System Message', | |
buttonNames: ['OK'] | |
}); | |
var scrollView = Ti.UI.createScrollView({ |