@@ -68,11 +68,51 @@ var observable = localforage.newObservable({
6868});
6969``` 
7070
71+ ## Cross-Tab Observables [ #5  ] ( https://github.com/localForage/localForage-observable/issues/5 )   
72+ Cross-tab event emition, observation and value change detection ** are disabled by default** .
73+ 
74+ In order to enable it, you have to:  
75+ 1 )  call the ` configObservables() `  method to start emmiting cross-tab events:
76+ ``` js 
77+ localforage .configObservables ({
78+   crossTabNotification:  true 
79+ });
80+ ``` 
81+ 2 )  create observables with cross-tab observation enabled:
82+ ``` js 
83+ var  observable =  localforage .newObservable ({
84+   crossTabNotification:  true ,
85+   changeDetection:  false 
86+ });
87+ ``` 
88+ The arguments passed to cross-tab observable callbacks,  will also have the ` crossTabNotification `  property set.
89+ 
90+ ### Cross-tab change detection  
91+ 
92+ Cross-tab observation with change detection is also supported, but with some limitations.
93+ The arguments passed to the callback will have the ` valueChange `  property set to true but:
94+ *  the ` oldValue `  will ** always**  be ` null `  and 
95+ *  the ` newValue `  will hold the value retrieved from the * local*  db at the time that the notification arrived.
96+ In that case you can use:
97+ ``` js 
98+ localforage .configObservables ({
99+   crossTabNotification:  true ,
100+   crossTabChangeDetection:  true 
101+ });
102+ var  observable =  localforage .newObservable ({
103+   crossTabNotification:  true 
104+ });
105+ ``` 
106+ 
107+ 
108+ 
71109## Examples  
72110*  [ Simple example] ( http://codepen.io/thgreasi/pen/pyXbRg ) 
73111*  [ Observing keys] ( http://codepen.io/thgreasi/pen/LNKZxQ ) 
74112*  [ Observing methods] ( http://codepen.io/thgreasi/pen/wGLWgL ) 
75113*  [ Simple RxJS 5 example] ( http://codepen.io/thgreasi/pen/wGLWmv ) 
114+ *  [ Cross-tab Observables] ( http://codepen.io/thgreasi/pen/NdObOW ) 
115+ *  [ Cross-tab Change Detection] ( http://codepen.io/thgreasi/pen/bgmBmb ) 
76116
77117## API  
78118``` typescript 
@@ -89,9 +129,11 @@ interface LocalForageObservableChange {
89129    methodName:  string ;
90130    oldValue:  any ;
91131    newValue:  any ;
132+     valueChange? :  boolean ;
92133    success? :  boolean ;
93134    fail? :  boolean ;
94135    error:  any ;
136+     crossTabNotification? :  string ;
95137}
96138``` 
97139
0 commit comments