当前位置: 首页>>代码示例>>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;未经允许,请勿转载。