4.41.24 • Published 5 days ago

@tramvai/core v4.41.24

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 days ago

title: '@tramvai/core'

sidebar_position: 1

Core

Ядро tramvai. В основном требуется для разработки модулей трамвая.

API

createApp

createApp - configuring, creating and running the application

createApp({ modules, bundles, providers })

  • modules - array with used modules in the application
  • bundles - object with used bundles with data in the application. The key is the bundle identifier, the value is Promise which returns the bundle
  • providers - an array with application providers, which will be added last in the DI (after module providers) and thus it will be possible to overwrite the implementation of the tokens
  • actions - array with global actions, which will be registered for all bundles and pages

Usage

import { createApp, provide } from '@tramvai/core';
import { RouterModule } from '@tramvai/module-router';
import { RenderModule } from '@tramvai/module-render';
import { ServerModule } from '@tramvai/module-server';

createApp({
  name: 'my-awesome-app',
  modules: [RouterModule, RenderModule, ServerModule],
  providers: [
    provide({
      provide: 'options',
      useValue: {},
    }),
  ],
  bundles: {
    mainDefault: () => import(/* webpackChunkName: "mainDefault" */ './bundles/mainDefault'),
  },
  actions: [loadDepositConfig],
});

After calling createApp, СommandLineRunner is started which performs the chain of actions necessary to initialize the application.

declareAction

declareAction - Method for creating asynchronous actions. It is used both for building chains of sagas and for performing global actions when building a response to a client

More about actions

declareAction({ name, fn, deps, conditions })

  • name - The name of the action, a unique identifier is expected
  • fn(...params) - Implementation of the action, this function will be called when the action is used, maybe async
    • this - action execution context that contains some helper functions and resolved deps
    • params - data passed to action
  • deps - List of providers that are needed for the action to work
  • conditions - List of conditions for the execution of the action
  • conditionsFailResult - see

Action Execution Context

Action execution context that contains some helper functions and resolved deps

Context has next fields:

  • deps - resolved deps that were specified when declaring action
  • executeAction - allows to execute another actions inside current one
  • getState - quick access to STORE_TOKEN.getState
  • dispatch - quick access to STORE_TOKEN.dispatch
  • abortSignal - instance of signal related to the current execution tree
  • abortController - instance of AbortController created exclusively for the current action execution

conditionsFailResult

Specifies the output of the action in case its conditions was not met during execution.

If conditions are not met for action, action's fn won't be executed in any way

Possible values for the conditionsFailResult:

  • empty - (default) execution will be resolved with undefined as a result
  • error - execution will be rejected with ConditionFailError

Usage example

import { declareAction } from '@tramvai/core';

declareAction({
  name: 'action log error',
  fn(payload) {
    this.deps.logger.error('ERROR');
  },
  deps: {
    logger: 'logger',
  },
  conditions: {
    requiredCoreRoles: ['god'],
  },
});

createBundle

createBundle(options: BundleOptions) - method to create a bundle.

Read more about bundles

Properties BundleOptions

  • name - Name of the bundle. The value will be used as a bundle identifier.
  • components: {} - An object with registered components for the bundle, which you can use in application routes
  • presets?: [] - A list of additional properties for the current bundle. This list is merged with the current properties. Needed to extract common parts, e.g. a set with actions and components for authorization. Reference - babel and eslint presets
  • actions?: [] - List of actions that will be registered globally for the bundle
  • reducers?: [] - List of reducers, which must be registered with the loading of the bundle

Usage

import { createBundle } from '@tramvai/core';
import { lazy } from '@tramvai/react';

createBundle({
  name: 'app/bundle',
  presets: [commonPreset],
  components: {
    'app/pages/MainPage': lazy(() => import('../pages/MainPage')),
    'app/pages/SecondPage': lazy(() => import('../pages/SecondPage')),
  },
  actions: [fooAction, barAction],
  reducers: [bazReducer],
});

Exported tokens

DI_TOKEN

Dependency Injection container implementation

APP_INFO_TOKEN

Information about running application

COMMAND_LINE_RUNNER_TOKEN

CommandLineRunner implementation

COMMAND_LINES_TOKEN

Commands for CommandLineRunner

3.41.38

10 days ago

4.41.24

5 days ago

4.41.22

8 days ago

4.41.21

10 days ago

5.5.4

10 days ago

5.6.2

5 days ago

5.6.0

8 days ago

3.41.36

19 days ago

4.41.17

19 days ago

4.41.19

16 days ago

5.5.2

16 days ago

5.5.1

19 days ago

3.41.35

30 days ago

4.41.15

26 days ago

4.41.14

30 days ago

5.4.3

26 days ago

5.4.2

30 days ago

4.41.11

1 month ago

5.4.0

1 month ago

5.1.2

1 month ago

4.41.8

1 month ago

5.0.2

1 month ago

5.1.1

1 month ago

5.1.0

1 month ago

3.41.33

1 month ago

3.41.32

1 month ago

3.41.31

2 months ago

3.41.30

2 months ago

4.41.7

1 month ago

4.41.2

2 months ago

4.41.1

2 months ago

4.41.6

1 month ago

4.41.5

1 month ago

4.41.4

1 month ago

4.41.3

2 months ago

4.37.0

2 months ago

4.36.2

2 months ago

4.36.0

2 months ago

4.39.1

2 months ago

4.39.0

2 months ago

4.38.0

2 months ago

3.41.19

2 months ago

3.41.16

3 months ago

3.41.13

3 months ago

3.41.11

3 months ago

4.33.3

3 months ago

3.41.26

2 months ago

3.41.24

2 months ago

3.41.22

2 months ago

4.35.0

3 months ago

4.34.4

3 months ago

4.34.1

3 months ago

4.40.3

2 months ago

4.40.1

2 months ago

4.40.5

2 months ago

4.33.2

3 months ago

4.33.1

3 months ago

3.41.9

3 months ago

4.32.6

3 months ago

4.32.5

3 months ago

3.41.4

3 months ago

3.41.5

3 months ago

3.41.6

3 months ago

3.41.7

3 months ago

4.25.0

4 months ago

4.26.4

4 months ago

4.26.5

4 months ago

4.26.7

4 months ago

4.26.0

4 months ago

4.26.1

4 months ago

4.26.2

4 months ago

4.26.9

3 months ago

4.14.0

6 months ago

4.24.0

4 months ago

4.24.1

4 months ago

4.13.0

6 months ago

4.27.1

3 months ago

3.40.49

5 months ago

3.40.48

5 months ago

3.40.47

5 months ago

3.40.46

5 months ago

3.40.44

5 months ago

3.40.43

5 months ago

4.21.0

4 months ago

3.40.69

3 months ago

3.40.67

4 months ago

3.40.65

4 months ago

3.40.62

4 months ago

3.40.61

4 months ago

3.40.60

4 months ago

4.20.1

4 months ago

3.40.58

4 months ago

3.40.57

4 months ago

4.32.0

3 months ago

3.40.53

4 months ago

3.40.51

4 months ago

4.32.2

3 months ago

4.12.5

6 months ago

4.23.0

4 months ago

4.22.0

4 months ago

4.20.7

4 months ago

4.20.9

4 months ago

4.31.0

3 months ago

3.40.76

3 months ago

3.40.73

3 months ago

3.40.70

3 months ago

4.18.1

5 months ago

4.18.3

5 months ago

4.18.4

5 months ago

4.18.0

5 months ago

4.18.5

5 months ago

4.17.0

5 months ago

4.29.1

3 months ago

3.41.0

3 months ago

3.41.1

3 months ago

3.41.3

3 months ago

4.19.0

5 months ago

4.19.2

5 months ago

4.19.3

5 months ago

4.19.4

5 months ago

4.19.5

4 months ago

4.12.4

6 months ago

4.12.2

6 months ago

3.40.33

6 months ago

3.40.32

6 months ago

4.11.1

6 months ago

4.11.2

6 months ago

4.10.1

6 months ago

3.40.30

6 months ago

4.9.1

6 months ago

4.9.0

7 months ago

3.40.28

7 months ago

4.8.6

7 months ago

3.40.26

7 months ago

3.40.25

7 months ago

4.8.4

7 months ago

4.8.3

7 months ago

3.40.21

7 months ago

4.7.1

7 months ago

3.40.20

7 months ago

4.7.0

7 months ago

4.4.6

7 months ago

3.40.17

7 months ago

4.4.5

7 months ago

4.4.4

7 months ago

3.40.16

7 months ago

4.4.1

7 months ago

4.4.3

7 months ago

3.40.14

7 months ago

3.40.13

7 months ago

4.3.1

7 months ago

3.40.11

7 months ago

4.3.0

7 months ago

3.40.6

7 months ago

3.40.7

7 months ago

4.2.1

7 months ago

4.2.0

7 months ago

4.1.0

7 months ago

4.0.6

7 months ago

3.40.5

7 months ago

4.0.5

8 months ago

4.0.4

8 months ago

3.40.4

8 months ago

3.38.0

8 months ago

3.37.10

8 months ago

3.37.8

8 months ago

3.37.7

8 months ago

3.37.5

8 months ago

3.37.1

9 months ago

3.34.0

9 months ago

3.33.2

9 months ago

3.33.0

9 months ago

3.32.3

10 months ago

3.31.0

10 months ago

3.31.2

10 months ago

3.31.3

10 months ago

3.30.1

10 months ago

3.27.5

10 months ago

3.27.3

10 months ago

3.27.4

10 months ago

3.27.0

10 months ago

3.26.3

10 months ago

3.26.2

10 months ago

3.25.5

10 months ago

3.25.6

10 months ago

3.25.3

10 months ago

3.25.2

10 months ago

3.24.3

11 months ago

3.25.0

11 months ago

3.24.1

11 months ago

3.24.0

11 months ago

3.23.0

11 months ago

3.21.0

11 months ago

3.19.0

11 months ago

3.19.1

11 months ago

3.17.0

12 months ago

2.160.25

12 months ago

3.15.1

12 months ago

3.16.0

12 months ago

3.12.0

12 months ago

3.14.1

12 months ago

3.14.0

12 months ago

3.13.0

12 months ago

3.10.2

12 months ago

3.11.0

12 months ago

2.139.3

1 year ago

2.139.2

1 year ago

3.2.0

1 year ago

2.149.0

1 year ago

2.149.1

1 year ago

2.160.21

12 months ago

2.160.12

1 year ago

2.160.17

12 months ago

2.160.19

12 months ago

2.160.10

1 year ago

2.118.1

1 year ago

3.0.2

1 year ago

3.0.0

1 year ago

2.130.10

1 year ago

2.117.4

1 year ago

2.130.11

1 year ago

2.117.2

1 year ago

2.117.0

1 year ago

2.150.0

1 year ago

2.150.1

1 year ago

2.160.4

1 year ago

2.160.2

1 year ago

2.160.1

1 year ago

2.119.5

1 year ago

2.119.4

1 year ago

2.119.3

1 year ago

2.119.2

1 year ago

2.119.0

1 year ago

3.5.0

1 year ago

3.4.1

1 year ago

2.152.2

1 year ago

2.152.3

1 year ago

2.152.1

1 year ago

3.4.6

1 year ago

3.4.5

1 year ago

3.3.2

1 year ago

2.151.0

1 year ago

2.142.1

1 year ago

2.142.0

1 year ago

2.154.0

1 year ago

2.141.2

1 year ago

2.141.1

1 year ago

2.130.9

1 year ago

2.130.7

1 year ago

2.130.6

1 year ago

2.153.3

1 year ago

2.130.4

1 year ago

2.153.1

1 year ago

2.153.2

1 year ago

2.153.0

1 year ago

2.121.2

1 year ago

3.9.1

12 months ago

3.9.0

12 months ago

2.133.5

1 year ago

2.133.4

1 year ago

3.10.0

12 months ago

2.133.2

1 year ago

2.156.1

1 year ago

2.133.0

1 year ago

2.143.0

1 year ago

2.143.1

1 year ago

2.120.0

1 year ago

3.7.0

12 months ago

2.132.1

1 year ago

2.155.0

1 year ago

2.132.0

1 year ago

2.123.4

1 year ago

2.146.1

1 year ago

2.123.3

1 year ago

2.123.2

1 year ago

2.123.1

1 year ago

2.146.0

1 year ago

2.145.0

1 year ago

2.145.1

1 year ago

2.122.0

1 year ago

2.134.0

1 year ago

2.125.4

1 year ago

2.148.1

1 year ago

2.125.3

1 year ago

2.125.2

1 year ago

2.148.0

1 year ago

2.125.0

1 year ago

2.137.0

1 year ago

2.147.1

1 year ago

2.124.0

1 year ago

2.159.5

1 year ago

2.159.6

1 year ago

2.159.4

1 year ago

2.159.1

1 year ago

2.159.2

1 year ago

2.112.0

1 year ago

2.111.1

1 year ago

2.111.0

1 year ago

2.95.0

2 years ago

2.95.4

2 years ago

2.103.1

2 years ago

2.94.27

2 years ago

2.94.24

2 years ago

2.94.23

2 years ago

2.94.25

2 years ago

2.104.0

1 year ago

2.104.2

1 year ago

2.104.3

1 year ago

2.104.4

1 year ago

2.106.3

1 year ago

2.106.4

1 year ago

2.106.5

1 year ago

2.105.0

1 year ago

2.110.0

1 year ago

2.106.2

1 year ago

2.108.1

1 year ago

2.109.0

1 year ago

2.109.1

1 year ago

2.98.2

2 years ago

2.98.0

2 years ago

2.100.0

2 years ago

2.108.0

1 year ago

2.97.2

2 years ago

2.97.0

2 years ago

2.101.0

2 years ago

2.101.1

2 years ago

2.102.1

2 years ago

2.94.17

2 years ago

2.94.16

2 years ago

2.94.2

2 years ago

2.94.19

2 years ago

2.94.18

2 years ago

2.94.13

2 years ago

2.94.12

2 years ago

2.94.6

2 years ago

2.94.15

2 years ago

2.94.4

2 years ago

2.94.9

2 years ago

2.94.7

2 years ago

2.94.8

2 years ago

2.94.0

2 years ago

2.79.9

2 years ago

2.79.7

2 years ago

2.79.6

2 years ago

2.79.5

2 years ago

2.79.4

2 years ago

2.82.0

2 years ago

2.93.0

2 years ago

2.78.2

2 years ago

2.78.1

2 years ago

2.89.2

2 years ago

2.92.1

2 years ago

2.77.0

2 years ago

2.92.0

2 years ago

2.76.2

2 years ago

2.91.1

2 years ago

2.87.0

2 years ago

2.90.0

2 years ago

2.85.1

2 years ago

2.84.0

2 years ago

2.84.2

2 years ago

2.75.0

2 years ago

2.74.0

2 years ago

2.73.1

2 years ago

2.73.0

2 years ago

2.72.0

2 years ago

2.72.5

2 years ago

2.72.4

2 years ago

2.72.3

2 years ago

2.67.1

2 years ago

2.70.1

2 years ago

2.70.0

2 years ago

2.67.0

2 years ago

2.66.0

2 years ago

2.66.2

2 years ago

2.66.3

2 years ago

2.65.9

2 years ago

2.56.0

2 years ago

2.56.5

2 years ago

2.56.1

2 years ago

2.56.2

2 years ago

2.64.0

2 years ago

2.49.5

2 years ago

2.49.2

2 years ago

2.49.3

2 years ago

2.49.0

2 years ago

2.63.0

2 years ago

2.48.3

2 years ago

2.48.0

2 years ago

2.51.2

2 years ago

2.51.0

2 years ago

2.51.1

2 years ago

2.59.2

2 years ago

2.59.3

2 years ago

2.59.4

2 years ago

2.59.0

2 years ago

2.50.0

2 years ago

2.61.1

2 years ago

2.61.2

2 years ago

2.34.0

2 years ago

2.45.0

2 years ago

2.45.1

2 years ago

2.33.1

2 years ago

2.33.3

2 years ago

2.33.2

2 years ago

2.44.2

2 years ago

2.32.0

2 years ago

2.31.0

2 years ago

2.39.0

2 years ago

2.39.3

2 years ago

2.39.2

2 years ago

2.37.3

2 years ago

2.37.1

2 years ago

2.37.0

2 years ago

2.40.0

2 years ago

2.36.0

2 years ago

2.47.3

2 years ago

2.47.0

2 years ago

2.47.2

2 years ago

2.47.1

2 years ago

2.35.0

2 years ago

2.22.0

2 years ago

2.21.0

2 years ago

2.21.1

2 years ago

2.29.0

2 years ago

2.20.0

2 years ago

2.20.1

2 years ago

2.28.0

2 years ago

2.27.0

2 years ago

2.26.2

2 years ago

2.26.0

2 years ago

2.25.1

2 years ago

2.24.1

2 years ago

2.24.0

2 years ago

2.24.3

2 years ago

2.11.0

2 years ago

2.4.0

2 years ago

2.3.0

2 years ago

2.10.2

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.0.2

2 years ago

2.0.7

2 years ago

2.0.0

2 years ago

2.7.0

2 years ago

2.7.1

2 years ago

1.110.2

2 years ago

1.110.0

2 years ago

2.6.2

2 years ago

1.109.0

2 years ago

2.5.0

2 years ago

1.108.1

2 years ago

1.94.5

3 years ago

1.94.2

3 years ago

1.94.1

3 years ago

1.94.0

3 years ago

1.103.0

2 years ago

1.102.1

2 years ago

1.96.0

3 years ago

1.105.3

2 years ago

1.105.2

2 years ago

1.95.2

3 years ago

1.95.1

3 years ago

1.95.0

3 years ago

1.104.2

2 years ago

1.105.6

2 years ago

1.98.0

3 years ago

1.99.1

3 years ago

1.97.0

3 years ago

1.106.0

2 years ago

1.101.8

2 years ago

1.101.6

2 years ago

1.101.3

2 years ago

1.101.4

2 years ago

1.101.2

2 years ago

1.101.9

2 years ago

1.90.6

3 years ago

1.90.4

3 years ago

1.90.2

3 years ago

1.90.1

3 years ago

1.93.1

3 years ago

1.92.3

3 years ago

1.92.2

3 years ago

1.92.0

3 years ago

1.84.0

3 years ago

1.84.2

3 years ago

1.89.1

3 years ago

1.91.1

3 years ago

1.91.0

3 years ago

1.85.0

3 years ago

1.82.1

3 years ago

1.82.2

3 years ago

1.82.3

3 years ago

1.79.0

3 years ago

1.76.2

3 years ago

1.78.0

3 years ago

1.78.1

3 years ago

1.78.2

3 years ago

1.78.3

3 years ago

1.81.0

3 years ago

1.77.0

3 years ago

1.74.0

3 years ago

1.75.0

3 years ago

1.75.1

3 years ago

1.72.1

3 years ago

1.72.2

3 years ago

1.76.0

3 years ago

1.76.1

3 years ago

1.73.0

3 years ago

1.56.0

3 years ago

1.63.1

3 years ago

1.67.0

3 years ago

1.48.3

3 years ago

1.70.0

3 years ago

1.70.2

3 years ago

1.51.0

3 years ago

1.55.0

3 years ago

1.53.4

3 years ago

1.53.6

3 years ago

1.57.1

3 years ago

1.53.5

3 years ago

1.60.2

3 years ago

1.60.1

3 years ago

1.64.0

3 years ago

1.68.0

3 years ago

1.68.1

3 years ago

1.49.1

3 years ago

1.49.0

3 years ago

1.71.0

3 years ago

1.71.1

3 years ago

1.52.0

3 years ago

1.58.1

3 years ago

1.58.0

3 years ago

1.61.0

3 years ago

1.65.0

3 years ago

1.65.1

3 years ago

1.53.2

3 years ago

1.53.1

3 years ago

1.55.2

3 years ago

1.55.1

3 years ago

1.59.0

3 years ago

1.55.4

3 years ago

1.55.3

3 years ago

1.55.5

3 years ago

1.62.0

3 years ago

1.62.1

3 years ago

1.66.0

3 years ago

1.66.1

3 years ago

1.50.1

3 years ago

1.50.0

3 years ago

1.50.3

3 years ago

1.50.2

3 years ago

1.54.0

3 years ago

1.50.4

3 years ago

1.37.1

3 years ago

1.44.4

3 years ago

1.48.2

3 years ago

1.48.1

3 years ago

1.44.5

3 years ago

1.29.1

3 years ago

1.29.4

3 years ago

1.29.2

3 years ago

1.29.3

3 years ago

1.32.1

3 years ago

1.34.0

3 years ago

1.38.0

3 years ago

1.41.0

3 years ago

1.41.2

3 years ago

1.45.0

3 years ago

1.26.1

3 years ago

1.46.11

3 years ago

1.46.10

3 years ago

1.35.1

3 years ago

1.39.1

3 years ago

1.35.6

3 years ago

1.39.0

3 years ago

1.35.4

3 years ago

1.35.8

3 years ago

1.46.6

3 years ago

1.35.10

3 years ago

1.27.0

3 years ago

1.46.5

3 years ago

1.46.8

3 years ago

1.46.7

3 years ago

1.46.9

3 years ago

1.30.2

3 years ago

1.30.0

3 years ago

1.30.1

3 years ago

1.36.0

3 years ago

1.47.0

3 years ago

1.28.2

3 years ago

1.28.0

3 years ago

1.28.4

3 years ago

1.31.1

3 years ago

1.31.0

3 years ago

1.25.4

3 years ago

1.25.0

3 years ago

1.25.1

3 years ago

1.23.0

3 years ago

1.22.2

3 years ago

1.14.1

3 years ago

1.14.0

3 years ago

1.10.3

3 years ago

1.12.0

3 years ago

1.10.2

3 years ago

1.11.0

3 years ago

1.15.0

3 years ago

1.13.1

3 years ago

1.13.0

3 years ago

1.11.1

3 years ago

1.15.2

3 years ago

1.15.1

3 years ago

1.9.11

3 years ago

1.10.0

3 years ago

1.9.10

3 years ago

1.9.9

3 years ago

1.9.8

3 years ago

1.9.7

3 years ago

1.9.6

3 years ago

1.9.1

3 years ago

1.9.5

3 years ago

1.9.4

3 years ago

1.9.3

3 years ago

1.9.2

3 years ago

1.9.0

3 years ago

1.8.8

3 years ago

1.8.7

3 years ago

1.8.6

3 years ago

1.8.5

3 years ago

1.8.4

3 years ago

1.8.2

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.8

3 years ago

1.7.7

3 years ago

1.8.3

3 years ago

1.7.3

3 years ago

1.7.6

3 years ago

1.7.5

3 years ago

1.7.4

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.0

3 years ago