diff --git a/packages/arch/README.md b/packages/arch/README.md index 1f6528b..7da444a 100644 --- a/packages/arch/README.md +++ b/packages/arch/README.md @@ -1,5 +1,7 @@ # `@archimedes/arch` +Refer to the [official documentation here](https://www.archimedesfw.io/docs/js/arch). + Different architectural pieces to use: - Use Cases @@ -10,100 +12,3 @@ Different architectural pieces to use: ## Usage `npm i @archimedes/arch -SE` - -_Note: If you want to use cache-link and your framework mangles the name of the classes (like Angular does) you should either disable that option or avoid using that link. For example, to disable that option in Angular when you build the application set `NG_BUILD_MANGLE=false`._ - -## Runner - -The runner configures a [chain of responsibility](https://refactoring.guru/design-patterns/chain-of-responsibility) which allows a use case to be processed through links. In order to create the chain you have to do this as soon as possible in your app: - -```ts -Runner.createChain([loggerLink, executorLink]) -``` - -You can configure the chain however you can, even dynamically: - -```ts -if (isProduction) { - Runner.createChain([executorLink]) -} else { - Runner.createChain([executorLink, loggerLink]) -} -``` - -_Note: The `executor-link` is always required, even if you use the `cache-link`._ - -## Links - -## ExecutorLink - -This link merely executes the use case. It is always needed if you want to execute the use cases. - -## LoggerLink - -This link logs information to the console about the execution of the use case, like parameters, result and name of the use case: - -```text -BazQry - Parameters: - - Result: - 42 -``` - -## NotificationLink - -This link is meant to capture errors occurred when executing a use case. This link should be placed after `ExecutorLink`. When an error occurs it will notify the `NotificationCenter`. From the UI you can subscribe to the `NotificationCenter` in order to show the user an error message: - -```ts -import { NotificationCenter } from './notification-center' -import { Observer } from './subscriber' - -class ErrorAlerter implements Observer { - update(publisher: NotificationCenter) { - publisher.notifications.map(x => ({ - ...x, - message: x.message ?? 'Error' - })) - } -} - -new NotificationCenter().register(new ErrorAlerter()) -``` - -### CacheLink - -#### Cache eviction - -You can automatically evict the cache of dependant use cases using the `EvictCache` decorator in conjunction with the `cache-link` link. If use case `a` depends on use case `b`, and use case `b` depends on use case `c` (`a` ➡ `b` ➡ `c`️) if we invalidate the cache of use case `a` we should evict the cache of use case `b` and `c` too. We should add this decorator to all use cases we want this handled. - -```ts -@EvictCache -export class AQry extends Query { - constructor(private readonly bQry: BQry) { - super() - } - - async internalExecute() { - return this.bQry.execute() - } -} -``` - -It's important to activate `emitDecoratorMetadata` to true in the `tsconfig.json` compiler's options. See the `examples` directory for more information. - -#### Cache invalidations - -If you want to set that certain commands or queries invalidate the cache of other commands and queries you can set the cache invalidations the `CacheInvalidations` class: - -```ts -CacheInvalidations.set(FooCmd.name, [BarQry.name]) -``` - -You can also use these invalidation policies: - -- ALL: The use case will invalidate all the cache of all the use cases -- NO_CACHE: The use case will never be cached - -```ts -CacheInvalidations.set(FooCmd.name, [InvalidationPolicy.ALL]) -``` diff --git a/packages/components/README.md b/packages/components/README.md index bd05c6e..7c53e4d 100644 --- a/packages/components/README.md +++ b/packages/components/README.md @@ -1,5 +1,7 @@ # `@archimedes/components` +Refer to the [official documentation here](https://www.archimedesfw.io/docs/js/components). + ## Usage 1. `npm i @archimedes/components -SE` diff --git a/packages/utils/README.md b/packages/utils/README.md index 2f2d9f4..6aef668 100644 --- a/packages/utils/README.md +++ b/packages/utils/README.md @@ -1,5 +1,7 @@ # `@archimedes/utils` +Refer to the [official documentation here](https://www.archimedesfw.io/docs/js/utils). + Different utilities to use: - datetime