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


TypeScript base.Models類代碼示例

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


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

示例1: expect

 it.skip("have all non-Widget view models from Python in the Models object", () => {
   const missing = []
   for (const name of core_defaults.all_view_model_names()) {
     if (!(name in Models.registered_names())) {
       missing.push(name)
     }
   }
   for (const m of missing) {
     console.log(`'Models.${m}' not found but there's a Python model '${m}'`)
   }
   expect(missing.length).to.equal(0)
 })
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:12,代碼來源:defaults.ts

示例2: it

 it("have all view models from Python in registered locations", () => {
   const registered: {[key: string]: boolean} = {}
   for (const name of Models.registered_names()) {
     registered[name] = true
   }
   const missing = []
   const all_view_model_names = concat([core_defaults.all_view_model_names(), widget_defaults.all_view_model_names()])
   for (const name of all_view_model_names) {
     if (!(name in registered)) {
       missing.push(name)
     }
   }
   for (const m of missing) {
     console.log(`'base.locations["${m}"]' not found but there's a Python model '${m}'`)
   }
   expect(missing.length).to.equal(0)
 })
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:17,代碼來源:defaults.ts

示例3: constructor

  constructor(attrs?: Partial<AnotherModel.Attrs>) {
    super(attrs)
  }

  static initClass(): void {
    this.prototype.type = 'AnotherModel'

    this.define<AnotherModel.Props>({
      bar: [ p.Number, 1 ],
    })
  }
}
AnotherModel.initClass()

Models.register('AnotherModel', AnotherModel)

namespace SomeModel {
  export type Attrs = p.AttrsOf<Props>
  export type Props = Model.Props & {
    foo: p.Property<number>
    child: p.Property<Model | null>
  }
}

interface SomeModel extends SomeModel.Attrs {}

class SomeModel extends Model {
  properties: SomeModel.Props

  constructor(attrs?: Partial<SomeModel.Attrs>) {
開發者ID:jsignell,項目名稱:bokeh,代碼行數:30,代碼來源:document.ts


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