2024-12-04 02:35:06 +08:00
|
|
|
import { HttpClient } from "core/http";
|
|
|
|
import { Serializable } from "interface/serializableType";
|
2024-12-20 00:34:54 +08:00
|
|
|
import React, { memo } from "react";
|
2024-11-30 22:24:35 +08:00
|
|
|
|
|
|
|
export class Template {
|
2024-12-18 21:54:37 +08:00
|
|
|
private readonly http: HttpClient;
|
2024-12-20 00:34:54 +08:00
|
|
|
private readonly MemoizedElement: React.MemoExoticComponent<
|
|
|
|
(props: { http: HttpClient; args: Serializable }) => React.ReactNode
|
|
|
|
>;
|
2024-12-05 02:13:54 +08:00
|
|
|
|
2024-11-30 22:24:35 +08:00
|
|
|
constructor(
|
2024-12-20 00:34:54 +08:00
|
|
|
element: (props: { http: HttpClient; args: Serializable }) => React.ReactNode,
|
2024-12-05 02:13:54 +08:00
|
|
|
services?: {
|
|
|
|
http?: HttpClient;
|
2024-12-20 00:34:54 +08:00
|
|
|
}
|
2024-12-05 02:13:54 +08:00
|
|
|
) {
|
|
|
|
this.http = services?.http || HttpClient.getInstance();
|
2024-12-20 00:34:54 +08:00
|
|
|
this.MemoizedElement = memo(element);
|
2024-12-05 02:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
render(args: Serializable) {
|
2024-12-20 00:34:54 +08:00
|
|
|
return React.createElement(this.MemoizedElement, {
|
2024-12-05 02:13:54 +08:00
|
|
|
http: this.http,
|
|
|
|
args,
|
|
|
|
});
|
2024-11-30 22:24:35 +08:00
|
|
|
}
|
2024-12-04 02:35:06 +08:00
|
|
|
}
|