LynxService API
Introduction
Lynx Service provides Lynx Engine with host-specific capabilities such as image handling, logging, and support for the Fetch API. Host apps have different requirements for the libraries they use. To accommodate these differences, Lynx Engine exposes the LynxService API so that host apps can provide their own service implementations.
Overall Design
Lynx Engine and Lynx Service are decoupled. Lynx Service implements the LynxService API exposed by Lynx Engine. Lynx Engine does not depend on a particular service implementation. At runtime, Lynx Engine uses its service lookup mechanism to find registered services and calls them through the LynxService API.
LynxService API
Lynx Engine provides the LynxService API, which defines the capabilities of Lynx Service. Service implementations must meet the API's requirements so that Lynx Engine can use these capabilities correctly.
1. Quick Access
Lynx provides a default implementation of Lynx Service that you can integrate directly.
2. Lynx Service Customization
If your app has custom requirements, you can also implement and register your own service. Using the Log Service as an example, the following steps show how to implement and register a custom Lynx Service:
Interface Implementation
-
- Implement
LynxServiceLogProtocol
- Implement
-
- Use the
LynxServiceRegisterto achieve automatic registration.
- Use the
-
- Implement
serviceBizIDandserviceScope. These two methods have no practical significance and will be removed later.
- Implement
-
- Implement
serviceType. It is required to return the type implemented by this Service. See LynxService.h for details.
- Implement
-
- (Recommended) Implement
sharedInstanceto make it a singleton class. Based on the current Lynx Service design, only one instance of a certain type of Service will be used globally. It is recommended to implement it as a singleton class.
- (Recommended) Implement
-
- Implement all the interfaces required by
LynxServiceLogProtocol.
- Implement all the interfaces required by
Service Register
Lynx Service has an automatic registration mechanism in iOS. In the implementation stage, the LynxServiceRegister macro has been used to complete the quick automatic registration.
If you use your own implementation of Lynx Service, please delete the default implementation provided by Lynx.
LCD tables only load in the browser