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


TypeScript stream.stream函數代碼示例

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


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

示例1: constructor

  protected constructor(name: string, type: RoleType, attributes: T, errors: Errors = new Errors()) {
    super();
    ValidatableMixin.call(this);

    this.type       = stream(type);
    this.name       = stream(name);
    this.attributes = stream(attributes);
    this.errors(errors);

    this.validatePresenceOf("name");
    this.validateFormatOf("name",
                          new RegExp("^[-a-zA-Z0-9_][-a-zA-Z0-9_.]*$"),
                          {message: "Invalid Id. This must be alphanumeric and can contain underscores and periods (however, it cannot start with a period)."});
    this.validateMaxLength("name", 255, {message: "The maximum allowed length is 255 characters."});
  }
開發者ID:GaneshSPatil,項目名稱:gocd,代碼行數:15,代碼來源:roles.ts

示例2: FollowersCtrl

export default function FollowersCtrl(userId: string): IRelationCtrl {

  socket.createDefault()

  const related: Mithril.Stream<Related[]> = stream([])
  const paginator: Mithril.Stream<Paginator<Related> | undefined> = stream(undefined)
  const isLoadingNextPage = stream(false)

  function loadNextPage(page: number) {
    isLoadingNextPage(true)
    xhr.followers(userId, page)
    .then(data => {
      isLoadingNextPage(false)
      paginator(data.paginator)
      related(related().concat(data.paginator.currentPageResults))
      redraw()
    })
    .catch(handleXhrError)
    redraw()
  }

  xhr.followers(userId, 1, true)
  .then(data => {
    paginator(data.paginator)
    related(data.paginator.currentPageResults)
    redraw()
  })
  .catch(handleXhrError)

  function setNewUserState(obj: Related, newData: xhr.RelationActionResult) {
    obj.relation = newData.following
    redraw()
  }

  return {
    related,
    loadNextPage,
    isLoadingNextPage,
    toggleFollowing: (obj: Related) => {
      if (obj.relation) xhr.unfollow(obj.user).then(d => setNewUserState(obj, d))
      else xhr.follow(obj.user).then(d => setNewUserState(obj, d))
    },
    challenge(id: string) {
      challengeForm.open(id)
    },
    paginator
  }
}
開發者ID:sepiropht,項目名稱:lichobile,代碼行數:48,代碼來源:followersCtrl.ts

示例3: constructor

 constructor(url: string,
             autoUpdate: boolean,
             name: string,
             destination: string,
             checkExternals: boolean,
             username: string,
             password: string,
             encryptedPassword: string,
             filter: Filter,
             invertFilter: boolean,
             errors: { [key: string]: string[] } = {}) {
   super(url, autoUpdate, name, destination, filter, invertFilter, errors);
   this.checkExternals = stream(checkExternals);
   this.username       = stream(username);
   this.password       = stream(plainOrCipherValue({plainText: password, cipherText: encryptedPassword}));
 }
開發者ID:GaneshSPatil,項目名稱:gocd,代碼行數:16,代碼來源:material.ts

示例4: oninit

export default function oninit(userId: string) {

  const user: Mithril.Stream<UserFullProfile | undefined> = stream(undefined)

  function setNewUserState(newData: Partial<UserFullProfile>) {
    Object.assign(user(), newData)
    redraw()
  }

  xhr.user(userId)
  .then(data => {
    user(data)
    redraw()
  })
  .then(session.refresh)
  .catch(utils.handleXhrError)

  return {
    user,
    isMe: () => session.getUserId() === userId,
    toggleFollowing() {
      const u = user()
      if (u && u.following) xhr.unfollow(u.id).then(setNewUserState)
      else if (u) xhr.follow(u.id).then(setNewUserState)
    },
    toggleBlocking() {
      const u = user()
      if (u && u.blocking) xhr.unblock(u.id).then(setNewUserState)
      else if (u) xhr.block(u.id).then(setNewUserState)
    },
    goToGames() {
      const u = user()
      if (u) {
        router.set(`/@/${u.id}/games`)
      }
    },
    goToUserTV() {
      const u = user()
      if (u) {
        router.set(`/@/${u.id}/tv`)
      }
    },
    challenge() {
      const u = user()
      if (u) {
        challengeForm.open(u.id)
      }
    },
    composeMessage() {
      const u = user()
      if (u) {
        router.set(`/inbox/new/${u.id}`)
      }
    }
  }
}
開發者ID:sepiropht,項目名稱:lichobile,代碼行數:56,代碼來源:userCtrl.ts

示例5: ImporterCtrl

export default function ImporterCtrl(): IImporterCtrl {

  const importing = stream(false)

  function submitOnline(pgn: string, analyse: boolean): Promise<OnlineGameData> {
    const data: {[i: string]: string } = { pgn }
    if (analyse) data.analyse = '1'

    return fetchJSON('/import', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        'X-Requested-With': 'XMLHttpRequest',
        'Accept': 'application/vnd.lichess.v' + globalConfig.apiVersion + '+json'
      },
      body: serializeQueryParameters(data)
    }, true)
  }

  window.addEventListener('keyboardDidHide', helper.onKeyboardHide)
  window.addEventListener('keyboardDidShow', helper.onKeyboardShow)

  return {
    importGame(pgn: string) {
      importing(true)
      redraw()
      submitOnline(pgn, settings.importer.analyse())
      .then(data => {
        router.set(`/analyse/online${data.url.round}`)
      })
      .catch(err => {
        importing(false)
        redraw()
        console.error(err)
        handleXhrError(err)
      })
    },
    importing
  }
}
開發者ID:mbensley,項目名稱:lichobile,代碼行數:40,代碼來源:ImporterCtrl.ts

示例6: constructor

 constructor(profiles: ElasticAgentProfile[]) {
   this.profiles = stream(profiles);
 }
開發者ID:GaneshSPatil,項目名稱:gocd,代碼行數:3,代碼來源:types.ts

示例7: constructor

 constructor(variables: Variable[]) {
   this.variables = stream(variables);
 }
開發者ID:Skarlso,項目名稱:gocd,代碼行數:3,代碼來源:new_validatable_mixin_spec.ts


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