File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
packages/xhr-http-handler/src Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,19 @@ export class XhrHttpHandler extends EventEmitter implements HttpHandler<XhrHttpH
73
73
private config ?: XhrHttpHandlerOptions ;
74
74
private configProvider : Promise < XhrHttpHandlerOptions > ;
75
75
76
+ /**
77
+ * @returns the input if it is an HttpHandler of any class,
78
+ * or instantiates a new instance of this handler.
79
+ */
80
+ public static create ( instanceOrOptions ?: HttpHandler < any > | XhrHttpHandlerOptions ) {
81
+ if ( typeof ( instanceOrOptions as any ) ?. handle === "function" ) {
82
+ // is already an instance of HttpHandler.
83
+ return instanceOrOptions as HttpHandler < any > ;
84
+ }
85
+ // input is ctor options or undefined.
86
+ return new XhrHttpHandler ( instanceOrOptions as XhrHttpHandlerOptions ) ;
87
+ }
88
+
76
89
public constructor ( options ?: XhrHttpHandlerOptions | Provider < XhrHttpHandlerOptions > ) {
77
90
super ( ) ;
78
91
if ( typeof options === "function" ) {
You can’t perform that action at this time.
0 commit comments