mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 04:06:39 +00:00
Migrated all service providers to typescript
This commit is contained in:
@@ -11,6 +11,7 @@ import provideTagsServices from '../tags/services/provideServices';
|
||||
import provideUtilsServices from '../utils/services/provideServices';
|
||||
import provideMercureServices from '../mercure/services/provideServices';
|
||||
import provideSettingsServices from '../settings/services/provideServices';
|
||||
import { ConnectDecorator } from './types';
|
||||
|
||||
type ActionMap = Record<string, any>;
|
||||
|
||||
@@ -20,11 +21,10 @@ const { container } = bottle;
|
||||
const lazyService = (container: IContainer, serviceName: string) => (...args: any[]) => container[serviceName](...args);
|
||||
const mapActionService = (map: ActionMap, actionName: string): ActionMap => ({
|
||||
...map,
|
||||
|
||||
// Wrap actual action service in a function so that it is lazily created the first time it is called
|
||||
[actionName]: lazyService(container, actionName),
|
||||
});
|
||||
const connect = (propsFromState: string[], actionServiceNames: string[] = []) =>
|
||||
const connect: ConnectDecorator = (propsFromState: string[], actionServiceNames: string[] = []) =>
|
||||
reduxConnect(
|
||||
propsFromState ? pick(propsFromState) : null,
|
||||
actionServiceNames.reduce(mapActionService, {}),
|
||||
|
||||
1
src/container/types.ts
Normal file
1
src/container/types.ts
Normal file
@@ -0,0 +1 @@
|
||||
export type ConnectDecorator = (props: string[], actions?: string[]) => any;
|
||||
Reference in New Issue
Block a user