Custom Serializers
Use cases
Third party CustomClass implements something important and requires methods to work with the data.
Simplest possible usage
PROBLEM
CURRENT SOLUTION 0 (userspace)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
state must be stored separate from CustomClass
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
user must know shape of state to call methods
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
state must be updated on every change
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
CustomClass must be checked + inited in every callback
SOLUTION 1 (changes useLexicalScope)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
state is exactly what is expected
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
state is just the object
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
state gets serialized only when needed
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
CustomClass gets inited only on scope resume
- customSerializer$ tags object with parse+stringify
- when pausing, customSerializer-serializer stores QRL of both + stringified value
- when resuming, useLexicalScope imports parser and parses value
- useLexicalScope is async only on qwikloader calls
- never from runtime calls
- runtime call can preserialize everything
- stringifier is needed on pause so either pause is async or needs pre-import
- changes useLexicalScope
- optimizer needs to write call differently
- runtime needs to check scope for QRLs to load before calling handler
SOLUTION 2 (pure runtime)
SOLUTION 3 (async)
This breaks everything :)
how qwikloader works when handler clicked