mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
refactor(core): zero circulars + esm ready (#10770)
This commit is contained in:
21
packages/core/http/http-shared.ts
Normal file
21
packages/core/http/http-shared.ts
Normal file
@ -0,0 +1,21 @@
|
||||
// Shared types and interfaces for http and image-source modules.
|
||||
// Only put platform-agnostic types/interfaces here.
|
||||
|
||||
// Example: (add more as needed)
|
||||
// TODO: look at removing this after circulars are completely resolved.
|
||||
export interface ImageSourceLike {
|
||||
toBase64String(format: string, quality?: number): string;
|
||||
// ... add other shared methods/properties as needed
|
||||
}
|
||||
|
||||
// Circular dependency resolution handling (http <--> image-source)
|
||||
let _getImage: (arg: any) => Promise<ImageSourceLike>;
|
||||
export function getImageRequest(arg: any): Promise<ImageSourceLike> {
|
||||
if (_getImage) {
|
||||
return _getImage(arg);
|
||||
}
|
||||
return Promise.reject(new Error('No getImage request handler set.'));
|
||||
}
|
||||
export function setGetImageRequest(fn: (arg: any) => Promise<ImageSourceLike>) {
|
||||
_getImage = fn;
|
||||
}
|
||||
Reference in New Issue
Block a user