Closed deskoh closed 4 years ago
Currently the generated app.interface.ts looks something like the following:
app.interface.ts
export type App = Application<{ 'messages': Message, // !code moduleExports // !end }>;
Propose to extract out the generic type for reuse:
export interface IApplication { 'messages': Message, // !code moduleExports // !end } export type App = Application<IApplication>;
For example, using a custom react hooks for feathers-reactive can be written something like:
import { useState, useEffect } from 'react'; import App from 'Feathers'; import { IApplication } from 'app.interface'; // Other service imports function useFeathersSubscription<T extends keyof IApplication>(serviceName: T, params?: Params) { // Assume non-paginated data. const [list, setList] = useState([] as IApplication[T][]); const service = App.service(serviceName); useEffect(() => { const subscription = service.watch() .find(params) .subscribe((results) => { // Assume non-paginated data. setList(results as IApplication[T][]); }); return () => { subscription.unsubscribe(); }; }, [service, params]); return [list, service]; }
That'd be great. I've build a little hack around that but yeah - this abstraction would help. Might give it a shot as PR
Currently the generated
app.interface.ts
looks something like the following:Propose to extract out the generic type for reuse:
For example, using a custom react hooks for feathers-reactive can be written something like: