mobx-react-lite#useLocalObservable TypeScript Examples

The following examples show how to use mobx-react-lite#useLocalObservable. 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: ApplicationStoreProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
ApplicationStoreProvider = <T extends LegendApplicationConfig>({
  children,
  config,
  pluginManager,
}: {
  children: React.ReactNode;
  config: T;
  pluginManager: LegendApplicationPluginManager;
}): React.ReactElement => {
  const navigator = useWebApplicationNavigator();
  const applicationStore = useLocalObservable(
    () => new ApplicationStore(config, navigator, pluginManager),
  );
  return (
    <ApplicationStoreContext.Provider value={applicationStore}>
      {children}
    </ApplicationStoreContext.Provider>
  );
}
Example #2
Source File: WebApplicationNavigatorProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
WebApplicationNavigatorProvider: React.FC<{
  children: React.ReactNode;
}> = ({ children }) => {
  const history = useHistory() as History;
  const navigator = useLocalObservable(
    () => new WebApplicationNavigator(history),
  );
  return (
    <WebApplicationNavigatorContext.Provider value={navigator}>
      {children}
    </WebApplicationNavigatorContext.Provider>
  );
}
Example #3
Source File: GraphManagerStateProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
GraphManagerStateProvider: React.FC<{
  children: React.ReactNode;
  pluginManager: GraphPluginManager;
  log: Log;
}> = ({ children, pluginManager, log }) => {
  const graphManagerState = useLocalObservable(
    () => new GraphManagerState(pluginManager, log),
  );
  return (
    <GraphManagerStateContext.Provider value={graphManagerState}>
      {children}
    </GraphManagerStateContext.Provider>
  );
}
Example #4
Source File: LegendQueryStoreProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
LegendQueryStoreProvider: React.FC<{
  children: React.ReactNode;
  pluginManager: LegendQueryPluginManager;
}> = ({ children, pluginManager }) => {
  const applicationStore = useApplicationStore<LegendQueryConfig>();
  const depotServerClient = useDepotServerClient();
  const graphManagerState = useGraphManagerState();
  const store = useLocalObservable(
    () =>
      new LegendQueryStore(
        applicationStore,
        depotServerClient,
        graphManagerState,
        pluginManager,
      ),
  );
  return (
    <LegendQueryStoreContext.Provider value={store}>
      {children}
    </LegendQueryStoreContext.Provider>
  );
}
Example #5
Source File: QuerySetupStoreProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
QuerySetupStoreProvider: React.FC<{
  children: React.ReactNode;
}> = ({ children }) => {
  const queryStore = useLegendQueryStore();
  const store = useLocalObservable(() => new QuerySetupStore(queryStore));
  return (
    <QuerySetupStoreContext.Provider value={store}>
      {children}
    </QuerySetupStoreContext.Provider>
  );
}
Example #6
Source File: DepotServerClientProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
DepotServerClientProvider: React.FC<{
  children: React.ReactNode;
  config: DepotServerClientConfig;
}> = ({ children, config }) => {
  const depotServerClient = useLocalObservable(
    () => new DepotServerClient(config),
  );
  return (
    <DepotServerClientContext.Provider value={depotServerClient}>
      {children}
    </DepotServerClientContext.Provider>
  );
}
Example #7
Source File: SDLCServerClientProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
SDLCServerClientProvider: React.FC<{
  children: React.ReactNode;
  config: SDLCServerClientConfig;
}> = ({ children, config }) => {
  const sdlcServerClient = useLocalObservable(
    () => new SDLCServerClient(config),
  );
  return (
    <SDLCServerClientContext.Provider value={sdlcServerClient}>
      {children}
    </SDLCServerClientContext.Provider>
  );
}
Example #8
Source File: LegendStudioStoreProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
LegendStudioStoreProvider: React.FC<{
  pluginManager: LegendStudioPluginManager;
  children: React.ReactNode;
}> = ({ pluginManager, children }) => {
  const applicationStore = useApplicationStore<LegendStudioConfig>();
  const sdlcServerClient = useSDLCServerClient();
  const depotServerClient = useDepotServerClient();
  const studioStore = useLocalObservable(
    () =>
      new LegendStudioStore(
        applicationStore,
        sdlcServerClient,
        depotServerClient,
        pluginManager,
      ),
  );
  return (
    <LegendStudioStoreContext.Provider value={studioStore}>
      {children}
    </LegendStudioStoreContext.Provider>
  );
}
Example #9
Source File: EditorStoreProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
EditorStoreProvider: React.FC<{
  children: React.ReactNode;
}> = ({ children }) => {
  const applicationStore = useApplicationStore<LegendStudioConfig>();
  const sdlcServerClient = useSDLCServerClient();
  const depotServerClient = useDepotServerClient();
  const graphManagerState = useGraphManagerState();
  const studioStore = useLegendStudioStore();
  const store = useLocalObservable(
    () =>
      new EditorStore(
        applicationStore,
        sdlcServerClient,
        depotServerClient,
        graphManagerState,
        studioStore.pluginManager,
      ),
  );
  return (
    <EditorStoreContext.Provider value={store}>
      {children}
    </EditorStoreContext.Provider>
  );
}
Example #10
Source File: ReviewStoreProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
ReviewStoreProvider = ({
  children,
}: {
  children: React.ReactNode;
}): React.ReactElement => {
  const editorStore = useEditorStore();
  editorStore.setMode(EDITOR_MODE.REVIEW);
  const store = useLocalObservable(() => new ReviewStore(editorStore));
  return (
    <ReviewStoreContext.Provider value={store}>
      {children}
    </ReviewStoreContext.Provider>
  );
}
Example #11
Source File: SetupStoreProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
SetupStoreProvider: React.FC<{
  children: React.ReactNode;
}> = ({ children }) => {
  const applicationStore = useApplicationStore<LegendStudioConfig>();
  const sdlcServerClient = useSDLCServerClient();
  const store = useLocalObservable(
    () => new SetupStore(applicationStore, sdlcServerClient),
  );
  return (
    <SetupStoreContext.Provider value={store}>
      {children}
    </SetupStoreContext.Provider>
  );
}
Example #12
Source File: ViewerStoreProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
ViewerStoreProvider: React.FC<{
  children: React.ReactNode;
}> = ({ children }) => {
  const editorStore = useEditorStore();
  editorStore.setMode(EDITOR_MODE.VIEWER);
  const store = useLocalObservable(() => new ViewerStore(editorStore));
  editorStore.setEditorMode(new ViewerEditorMode(store));
  return (
    <ViewerStoreContext.Provider value={store}>
      {children}
    </ViewerStoreContext.Provider>
  );
}
Example #13
Source File: LegendTaxonomyStoreProvider.tsx    From legend-studio with Apache License 2.0 6 votes vote down vote up
LegendTaxonomyStoreProvider: React.FC<{
  children: React.ReactNode;
  pluginManager: LegendTaxonomyPluginManager;
}> = ({ children, pluginManager }) => {
  const applicationStore = useApplicationStore<LegendTaxonomyConfig>();
  const taxonomyServerClient = new TaxonomyServerClient(
    applicationStore.config.currentTaxonomyTreeOption.url,
  );
  const depotServerClient = useDepotServerClient();
  const graphManagerState = useGraphManagerState();
  const store = useLocalObservable(
    () =>
      new LegendTaxonomyStore(
        applicationStore,
        taxonomyServerClient,
        depotServerClient,
        graphManagerState,
        pluginManager,
      ),
  );
  return (
    <LegendTaxonomyStoreContext.Provider value={store}>
      {children}
    </LegendTaxonomyStoreContext.Provider>
  );
}