當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript jb-rx.Observable類代碼示例

本文整理匯總了TypeScript中jb-ui/jb-rx.Observable的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observable類的具體用法?TypeScript Observable怎麽用?TypeScript Observable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Observable類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getProbe

 function getProbe() {
   if (cmp.probeResult)
     return [cmp.probeResult];
   var _probe = jb_rx.Observable.fromPromise(ctx.run({$: 'studio.probe', path: ctx.params.path }));
   _probe.subscribe(res=>
     cmp.probeResult = res);
   // do not wait more than 500 mSec
   return _probe.race(jb_rx.Observable.of({finalResult: [ctx] }).delay(500))
     .catch(e=>
         jb.logException(e,'in probe exception'))
 }
開發者ID:ArtwareSoft,項目名稱:jbart5-ng,代碼行數:11,代碼來源:studio-suggestions.ts

示例2: compAsStr

	impl : (ctx,force) => 
		jb_rx.Observable.from(jb.entries(modified))
			.filter(x=>x)
			.concatMap(toSave=>{
				var comp = toSave[0], val = toSave[1];
				message('saving ' + comp);
				if (force && !val.original)
					val.original = `jb.component('${comp}', {`;

				return $.ajax({ 
					url: `/?op=saveComp&comp=${comp}&project=${ctx.exp('%$globals/project%')}&force=${force}`, 
					type: 'POST', 
					data: JSON.stringify({ original: val && val.original, toSave: compAsStr(comp) }),
					headers: { 'Content-Type': 'application/json; charset=UTF-8' } 
				}).then(
					res=>({ res: res , comp: comp }),
					e=> { throw { e: e , comp: comp } }
				)

				// return fetch(`/?op=saveComp&comp=${comp}&project=${ctx.exp('%$globals/project%')}&force=${force}`, {
				// 	method: 'post',  
				// 	body: JSON.stringify({ original: val && val.original, toSave: compAsStr(comp) }),
				//     headers: { 'Content-type': 'application/json; charset=UTF-8' },  
				// })
			})
			.catch(e=>{
				message('error saving: ' + e.e);
				jb.logException(e,'error while saving ' + e.comp)
			})
			.subscribe(entry=>{
				var result = entry.res;
				message((result.type || '') + ': ' + (result.desc || '') + (result.message || ''), result.type != 'success');
				if (result.type == 'success')
					delete modified[entry.comp];
			})
開發者ID:ArtwareSoft,項目名稱:jbart5-ng,代碼行數:35,代碼來源:studio-save.ts

示例3:

 beforeInit: cmp => {
     cmp.jbWatchGroupChildrenEm = (cmp.jbWatchGroupChildrenEm || jb_rx.Observable.of())
         .merge(cmp.jbEmitter
           .filter(x => x == 'check')
           .merge(
             pathChangesEm.takeUntil( cmp.jbEmitter.filter(x=>x =='destroy') ).do(fixer=>
               jb.writeValue(path_ref,fixer.fix(jb.val(path_ref))))
           )
           .map(()=> jb.val(path_ref))
           .distinctUntilChanged()
           .map(val=> {
               var ctx2 = (cmp.refreshCtx ? cmp.refreshCtx() : cmp.ctx);
               return context.vars.$model.controls(ctx2)
           })
       )
 },
開發者ID:ArtwareSoft,項目名稱:jbart5-ng,代碼行數:16,代碼來源:studio-path.ts

示例4: CompOption

      afterViewInit: cmp=> {
        var input = $(cmp.elementRef.nativeElement).findIncludeSelf('input')[0];
        if (!input)
          return;
        suggestionCtx.input = input;
        var inputClosed = cmp.jbEmitter.filter(x=>x =='destroy');

        cmp.keyEm = jb_rx.Observable.fromEvent(input, 'keydown')
          .takeUntil(inputClosed);
        suggestionCtx.keyEm = cmp.keyEm;
        suggestionCtx.closeAndWriteValue = _ =>{
          ctx.params.closeFloatingInput();
          var option = input.value.indexOf('=') == 0 ? new CompOption(input.value.substr(1)) : new ValueOption();
          option.writeValue(cmp.ctx);
        };
        suggestionCtx.refresh = _ =>
          cmp.changeDt.detectChanges();

        cmp.keyEm.filter(e=> e.keyCode == 13)
            .subscribe(e=>{
              if (!suggestionCtx.show || suggestionCtx.options.length == 0)
                suggestionCtx.closeAndWriteValue()
            })

        cmp.keyEm.filter(e=> e.keyCode == 27)
            .subscribe(e=>{
              ctx.params.closeFloatingInput();
            })

        suggestionCtx.suggestionEm = cmp.keyEm
          .filter(e=> e.keyCode != 38 && e.keyCode != 40 && e.key != 'Shift')
          .delay(1) // we use keydown - let the input fill itself
          .debounceTime(20) // solves timing of closing the floating input
          .filter(e=>
            suggestionCtx.show = new suggestions(input,ctx.params.expressionOnly).suggestionsRelevant() )
          .catch(e=>
            console.log(1,e))
          .map(e=>
            input.value)
//          .do(x=>console.log(0,x))
          .distinctUntilChanged()
//          .do(x=>console.log(1,x))
          .flatMap(e=>
            getProbe())
          .map(res=>
              res && res.finalResult && res.finalResult[0] && res.finalResult[0].in)
          .map(probeCtx=> 
            new suggestions(input,ctx.params.expressionOnly).extendWithOptions(probeCtx,ctx.params.path))
          .catch(e=>
            console.log(2,e))
          .distinctUntilChanged((e1,e2)=>
            e1.key == e2.key)
          .do(e=>jb_logPerformance('suggestions',e))
          .catch(e=>
            console.log(3,e))

        function getProbe() {
          if (cmp.probeResult)
            return [cmp.probeResult];
          var _probe = jb_rx.Observable.fromPromise(ctx.run({$: 'studio.probe', path: ctx.params.path }));
          _probe.subscribe(res=>
            cmp.probeResult = res);
          // do not wait more than 500 mSec
          return _probe.race(jb_rx.Observable.of({finalResult: [ctx] }).delay(500))
            .catch(e=>
                jb.logException(e,'in probe exception'))
        }
      }
開發者ID:ArtwareSoft,項目名稱:jbart5-ng,代碼行數:68,代碼來源:studio-suggestions.ts


注:本文中的jb-ui/jb-rx.Observable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。