Observable<T> constructor

Observable<T>(
  1. T state, {
  2. String? cacheKey,
  3. _Decoder? decoder,
  4. _PreContent? preWrite,
  5. _PreContent? preRead,
})
  • 设置cacheKey 即为生效,状态变化即会缓存,数据对象需要实现fromJson和toJson
  • 如果存在缓存,使用缓存赋值state
  • 写入前处理数据回调,读取前处理数据回调,一般用于加解密
  • cacheKey is set to take effect, state changes are cached, and data objects need to implement fromJson and toJson
  • if a cache exists, use the cache assignment state
  • write pre-processing data callback, read pre-processing data callback, generally used for encryption and decryption

Implementation

Observable(this.state,
    {String? cacheKey,
    _Decoder? decoder,
    _PreContent? preWrite,
    _PreContent? preRead}) {
  _preWrite = preWrite;
  _preRead = preRead;
  _decoder = decoder;
  _initCache(cacheKey);
  _init(cacheKey);
}