mobx#isObservable TypeScript Examples

The following examples show how to use mobx#isObservable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseNodeModel.ts    From LogicFlow with Apache License 2.0 6 votes vote down vote up
/**
   * 获取被保存时返回的数据
   * @overridable 支持重写
   */
  getData(): NodeData {
    const { x, y, value } = this.text;
    let { properties } = this;
    if (isObservable(properties)) {
      properties = toJS(properties);
    }
    const data: NodeData = {
      id: this.id,
      type: this.type,
      x: this.x,
      y: this.y,
      properties,
    };
    if (this.graphModel.overlapMode === OverlapMode.INCREASE) {
      data.zIndex = this.zIndex;
    }
    if (value) {
      data.text = {
        x,
        y,
        value,
      };
    }
    return data;
  }
Example #2
Source File: DomainObserverHelper.ts    From legend-studio with Apache License 2.0 6 votes vote down vote up
observe_PackageTree = async (
  metamodel: Package,
  context: ObserverContext,
): Promise<Package> => {
  if (isObservable(metamodel)) {
    return metamodel;
  }

  _observe_Abstract_Package(metamodel);

  await Promise.all(
    metamodel.children.map(async (child) => {
      if (child instanceof Package) {
        await observe_PackageTree(child, context);
      } else {
        await promisify(() => observe_PackageableElement(child, context));
      }
    }),
  );

  return metamodel;
}
Example #3
Source File: GraphObserverHelper.ts    From legend-studio with Apache License 2.0 6 votes vote down vote up
observe_Graph = (metamodel: PureModel): PureModel => {
  if (isObservable(metamodel)) {
    return metamodel;
  }
  observe_Abstract_BasicModel(metamodel);

  makeObservable(metamodel, {
    generationModel: observable,
    dependencyManager: observable,

    sectionIndices: computed,
    profiles: computed,
    enumerations: computed,
    measures: computed,
    classes: computed,
    types: computed,
    associations: computed,
    functions: computed,
    stores: computed,
    databases: computed,
    mappings: computed,
    services: computed,
    runtimes: computed,
    connections: computed,
    generationSpecifications: computed,
    fileGenerations: computed,
    dataElements: computed,

    allElements: computed,
    allOwnTestables: computed,
  });

  observe_DependencyManager(metamodel.dependencyManager);

  return metamodel;
}
Example #4
Source File: CoreObserverHelper.ts    From legend-studio with Apache License 2.0 5 votes vote down vote up
skipObserved =
  <T>(observer: (metamodel: T) => T): ((metamodel: T) => T) =>
  (metamodel: T) =>
    isObservable(metamodel) ? metamodel : observer(metamodel)
Example #5
Source File: CoreObserverHelper.ts    From legend-studio with Apache License 2.0 5 votes vote down vote up
skipObservedWithContext =
  <T>(
    observer: (metamodel: T, context: ObserverContext) => T,
  ): ((metamodel: T, context: ObserverContext) => T) =>
  (metamodel: T, context: ObserverContext) =>
    isObservable(metamodel) ? metamodel : observer(metamodel, context)