• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript stream.stream函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript stream.Stream类代码示例发布时间:2022-05-25
下一篇:
TypeScript stream.merge函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap