LynxTemplateResourceFetcher

LynxTemplateResourceFetcher is defined inside LynxEngine and injected from outside to implement the resource loading interface of Bundle and Lazy Bundle etc.

Android

Interface definition:

LynxTemplateResourceFetcher.java
abstract class LynxTemplateResourceFetcher {

   @Required
   void fetchTemplate(LynxResourceRequest request, LynxResourceCallBack<TemplateProviderResult> callback);

}

Method introduction:

fetchTemplate

LynxEngine internally calls this method to obtain the contents of Bundle and Lazy Bundle. The returned result type can contain byte[] or TemplateBundle;

NOTE

This method must be implemented;

Injection:

Inject when constructing a LynxView using LynxViewBuilder:

LynxViewBuilder builder = new LynxViewBuilder();
builder.setTemplateResourceFetcher(new ExampleTemplateResourceFetcher());

Also enable this capability in LynxViewBuilder:

LynxViewBuilder builder = new LynxViewBuilder();
builder.setTemplateResourceFetcher(new ExampleTemplateResourceFetcher());
builder.setEnableGenericResourceFetcher(LynxBooleanOption.TRUE);

iOS

Interface definition:

LynxTemplateResourceFetcher.h
@protocol LynxTemplateResourceFetcher <NSObject>

/**
 * fetch Bundle etc.
 *
 * @param request
 * @param callback response with the requiring content file: NSData* or TemplateBundle
 */
@required
- (void)fetchTemplate:(LynxResourceRequest* _Nonnull)request
           onComplete:(LynxTemplateResourceCompletionBlock _Nonnull)callback;

@end

NS_ASSUME_NONNULL_END

Method introduction:

fetchTemplate

LynxEngine internally calls this method to obtain the contents of AppBundle and LazyBundle. The returned result type can contain NSData* or TemplateBundle;

NOTE

This method must be implemented;

Injection:

Inject when constructing a LynxView using LynxViewBuilder:

LynxViewBuilder *builder = [[LynxViewBuilder alloc] init];
builder.templateResourceFetcher = [[ExampleTemplateResourceFetcher alloc] init];

Also enable this capability in LynxViewBuilder:

LynxViewBuilder *builder = [[LynxViewBuilder alloc] init];
builder.templateResourceFetcher = [[ExampleTemplateResourceFetcher alloc] init];
builder.enableGenericResourceFetcher = LynxBooleanOptionTrue;

Compatibility

LCD tables only load in the browser

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.