import { App } from ‘ionic-angular’;
http://blog.turn.tw/?p=1539
View Model 2: 不具有行為,只是等別人塞資料進去的模板(template)。 MVC: 具有監視Model的行為,並以此去改變呈現(presentation)。 Controller Model 2: 接收請求與參數,轉交給Model處理,再把結果(最新的資料)塞進View。 MVC: 接收請求與參數,轉交給Model處理。沒其他事了。 Model Model 2: 接收Controller傳來的參數,回傳結果。 MVC: 接收Controller傳來的參數,將結果通知View。
https://www.zybuluo.com/cxm-2016/note/467206
==========
http://www.itread01.com/articles/1476290449.html
Operators一句話介紹(RxJava版)
Cold Observables
在第一個subscriber訂閱後才執行事件發送的Observables,默認普通Observables都是這個類型
Cold Observables對於每個訂閱的subscriber執行一次事件發送過程的重演,每次事件實體將重新生成,尤其對於每次隨機生成的數值將不保證保持一致性
參考:Observable vs ConnectableObservable
Hot Observables
從創建一刻開始立即發送事件,此後進行訂閱的subscribers僅能接收在訂閱後發送的事件
Hot Observables發送的事件實體對象在所有subscribers之間進行共享
Connectable Observables
在connect()調用時進行事件發送動作,不論是否有subscriber執行了訂閱。實際上是把該Observable轉換為Hot Observable,發送的事件實體對象在所有subscribers之間進行共享
Creating
create / just(T..) / from(Iterable/Array) 常用Observable構建方式
defer(Func0) 延遲生成Observable,每次subscribe時生成新的Observable
range(start, len) 發送從start開始的數字序列,長度為len,值區間為[start, start+len-1]
repeat(n) 非直接構造器,將上個構造好的Observable重復n次發送(前一次Observable發送onCompleted後再啟動下一次的重訂閱),不傳參時表示無限repeat
repeatWhen(Func1<Observable, Observable) 通過函數判斷是否進行下一次重訂閱,可參考retryWhen(Func1)解釋
interval(time) 周期性發送一個序號數字(從0開始的正整數序列順序)
timer(time) 在指定時間後發送數字0
Transforming
map(Func1) / cast(class) 將單個事件轉型為另一類型事件或據此構造新的次級Observable並匯入單一事件流
flatMap / flatMapIterable 依據單個事件構造新的次級Observable或Iterable並匯入單一事件流,flatMap不保證發送順序 (允許交叉發送)
concatMap / switchMap concatMap是有序化版本的flatMap,switchMap是強時效版本的flatMap(下個次級Observable開始發送事件時,前面的次級Observable將自動被終止發送)
buffer(count/time) 按數量、時間緩存前後多個事件為一個個小組,再按小組為單位逐次發送
window(count/time) 類似於buffer,但緩存的小組以子Observable形式作為事件發送 (需要二次subscribe分發)
groupBy(KeyFunc, ValueFunc) 通過函數獲得每個事件的Key值進行分組,並將事件轉換為Value類型,返回發送GroupedObservable類型事件的包裹Observable (需要二次subscribe分發)
scan(Func2(x1, x2)) 前一次實際發送的事件x1與本次該發送的源事件x2通過函數計算,其結果作為本次實際發送的的事件,第0個初始事件不經過函數直接發送
Filtering
https://github.com/angular/angularfire2/issues/380
subscription.unsubscribe();
Observable.interval + take(1)
Maybe
Object.assign but sub itme only reference
So JSON.parse(JSON.stringify(theObject))
https://www.microsoft.com/en-us/download/details.aspx?id=50042
1、ionic start sendnotify blank –v2
2、cordova plugin add cordova-plugin-whitelist
3、src/index.html
4、ionic serve ====if success=====
5、home.ts
add
import { Http, Headers, RequestOptions } from ‘@angular/http’;
import ‘rxjs/add/operator/map’;
add constructor(private http: Http
sendnotify_devicetoken(devictoken) {
let url = ‘https://fcm.googleapis.com/fcm/send';
let headers = new Headers({ ‘Content-Type’: ‘application/json’,
‘Authorization’: ‘key=your key’
});
let options = new RequestOptions({ headers: headers });
let body = {
“notification”:{