constructor(public ref:string, public cancelCallback) {
   this.value = Rx.Observable.fromEventPattern(
     _ => this.ref.on('value', _),
     _ => this.ref.off('value', _)
     )
     .map(snapshot => {
       if (typeof snapshot.val() === 'object' && snapshot.val() !== null)
           return Object.assign({'.key':snapshot.key()}, snapshot.val())
         else
           return {'.key':snapshot.key(), '.value':snapshot.val()}
     })
   
 }
Ejemplo n.º 2
0
 observable1 = constructorZone1.run(() => {
   return Rx.Observable.fromEventPattern(
     (handler: any) => {
       expect(Zone.current.name).toEqual(constructorZone1.name);
       button.addEventListener('click', handler);
       log.push('addListener');
     },
     (handler: any) => {
       expect(Zone.current.name).toEqual(constructorZone1.name);
       button.removeEventListener('click', handler);
       document.body.removeChild(button);
       log.push('removeListener');
     }
   );
 });
Ejemplo n.º 3
0
 observable1 = constructorZone1.run(() => {
   const handler = function() {
     log.push('handler');
   };
   return Rx.Observable.fromEventPattern(
       () => {
         expect(Zone.current.name).toEqual(constructorZone1.name);
         document.addEventListener('click', handler);
         log.push('addListener');
       },
       () => {
         expect(Zone.current.name).toEqual(constructorZone1.name);
         document.removeEventListener('click', handler);
         log.push('removeListener');
       });
 });
  constructor(public ref:string) {

    this.items = Rx.Observable.fromEventPattern(
      _ => this.ref.on('value', _),
      _ => this.ref.off('value', _)
      )
      .map(snapshot => snapshot.val())
      .map(value => {
        return Object
          .keys(value)
          .map(key => {
            if (typeof value[key] === 'object' && value !== null)
              return Object.assign({'.key':key}, value[key])
            else
              return {'.key':key, '.value':value[key]}
          })
      }) 
  }