@shopify/app-bridge-host
Version:
App Bridge Host contains components and middleware to be consumed by the app's host, as well as the host itself. The middleware and `Frame` component are responsible for facilitating communication between the client and host, and used to act on actions se
41 lines (40 loc) • 1.39 kB
TypeScript
import { Reducer } from 'redux';
import { Store } from '../../store';
import { ApiClientConfig, Application } from '../../types';
export interface ApiConfig extends ApiClientConfig {
hostName?: string;
}
export interface ApiConfigWithRouter extends ApiConfig {
hostName: string;
}
export interface GetApiOption<Config, LocalActions> {
config: Config;
actions: LocalActions;
subscribe: Application['hostSubscribe'];
getState: Application['getState'];
dispatch: Application['dispatch'];
}
export interface GetApi<Api, Config, LocalActions> {
(options: GetApiOption<Config, LocalActions>): Api;
}
/**
* The interface for a dynamic feature
* @public
* */
export interface Feature<LocalStore, LocalActions> {
/** actions for the feature*/
actions: LocalActions;
/** the key matching the property name in the store*/
key: keyof Store;
/** the reducer for the feature*/
reducer: Reducer<LocalStore>;
/** optional initial state for the feature*/
initialState?: LocalStore;
}
export interface FeatureWithApi<LocalStore, LocalActions, Api> extends Feature<LocalStore, LocalActions> {
getApi: GetApi<Api, ApiConfig, LocalActions>;
}
export interface FeatureWithRouterApi<LocalStore, LocalActions, Api> extends Feature<LocalStore, LocalActions> {
getApi: GetApi<Api, ApiConfigWithRouter, LocalActions>;
requiresRouter: true;
}