Skip to content

Commit

Permalink
feat: add UseXComponentAPI type extending both UseXBusAPI & UseAliasAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
annacv committed Mar 20, 2024
1 parent 20d2f90 commit 79d0432
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions packages/x-components/src/composables/use-$x.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { XComponentAPI } from '../plugins';
import { useAliasApi } from './use-alias-api';
import { useXBus } from './use-x-bus';
import { UseAliasAPI, useAliasApi } from './use-alias-api';
import { useXBus, UseXBusAPI } from './use-x-bus';

/**
* Function which returns the `$x` object from the current component instance.
Expand All @@ -9,9 +8,17 @@ import { useXBus } from './use-x-bus';
*
* @public
*/
export function use$x(): XComponentAPI {
export function use$x(): UseXComponentAPI {
const xAliasAPI = useAliasApi();
const xBusAPI = useXBus();
const $x = Object.assign(xAliasAPI, xBusAPI);
return $x;
}

/**
* The XComponentAPI exposes access to the {@link @empathyco/x-bus#XBus}, and store aliases to the
* components.
*
* @public
*/
export interface UseXComponentAPI extends UseXBusAPI, UseAliasAPI {}
2 changes: 1 addition & 1 deletion packages/x-components/src/composables/use-x-bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ interface PrivateExtendedVueComponent extends Vue {
xComponent?: Vue | undefined;
}

interface UseXBusAPI {
export interface UseXBusAPI {
/* eslint-disable jsdoc/require-description-complete-sentence */
/** {@inheritDoc XBus.(on:1)} */
on: XBus<XEventsTypes, WireMetadata>['on'];
Expand Down

0 comments on commit 79d0432

Please sign in to comment.