Example #1
0
    /**
     * Creates an instance of Camera.
     * 
     * @param {HTMLCanvasElement} mCanvas
     */
    constructor(private mCanvas: HTMLCanvasElement) {
        super();
        this.mSizeChanged$ = new ReplaySubject<IBounds>(1);

        this.mOnSizeChanged = this.mSizeChanged$.asObservable().debounceTime(200);
        this.refreshProjection();
    }
Example #2
0
export function MemorySource(map: MemoryMap) {
  const subject = new ReplaySubject();
  try {
    _recursiveMemorySource(subject, map, '');
    subject.complete();
  } catch (err) {
    subject.error(err);
  }
  return subject.asObservable();
}
    private async _updateUserProgramInCache(program: UserFacingProgram, resp: any): Promise<boolean> {
        if (resp.result === 'updated' || resp.result === 'created') {
            const cache = await this._cache.asObservable().take(1).toPromise();
            const val = cache.find(p => p.guid === program.guid);

            if (val) {
                val.user = program;
                this._cache.next(cache);
            } else {
                this._cache.next([{guid: program.guid, application: [], user: program},  ...cache]);
            }
            return true;
        }
        return false;
    }
Example #4
0
function _recursiveFileSource(p: string, root: string): Observable<Entry> {
  const subject = new ReplaySubject();

  access(p, fs.R_OK)
    .then(() => stat(p))
    .catch(err => { throw new FileSystemException(err); })
    .then((stats) => {
      if (stats.isFile()) {
        if (p == root) {
          // Root is a file. Error.
          throw new SourceRootMustBeDirectoryException();
        }
        return readFile(p, 'utf-8')
          .then((data) => {
            const subpath = path.relative(root, p);
            subject.next(new StaticEntry(path.dirname(subpath), path.basename(subpath), data));
          });
      } else {
        return readdir(p)
          .then((files) => {
            return Promise.all(files.map((file) => {
              return _recursiveFileSource(path.join(p, file), root)
                .forEach((value) => {
                  if (value) {
                    subject.next(value);
                  }
                });
            }));
          });
      }
    })
    .then(() => subject.complete())
    .catch((err) => subject.error(err));

  return subject.asObservable();
}
 return input$.flatMap(data => Observable.zip(Observable.of(data), this._cache.asObservable()))
 return this._deleteProgram(guid).do(res => {
     if (res) {
         this._cache.asObservable().take(1).subscribe(cache => this._cache.next(cache.filter(p => p.guid !== guid)))
     }
 })
 getPrograms(): Observable<ApplicationFacingProgram[]> {
     return this._cache.asObservable();
 }
 findProgram(guid: string): Observable<Program> {
     return this._cache.asObservable()
         .map(programs => programs.find(this._findProgram(guid)))
         .map(p => p !== undefined ? new Program(p, this.fb) : null)
         .map(p => p === null ? new Program(undefined, this.fb) : p)
 }