alibaba / GaiaX

动态模板引擎是一套轻量化、跨平台、高性能的纯原生移动端卡片渲染动态化解决方案
https://youku-gaiax.github.io/
Apache License 2.0
1.21k stars 145 forks source link

GXTemplateSourceProtocal priority 定义 #382

Closed JohnTsaii closed 1 year ago

JohnTsaii commented 1 year ago

描述这个问题

实现GXTemplateSourceProtocal时发现设置了priority为100的source 不会生效,查看源码发现priority一定要小于99大于0。为什么要有这个限制?

- (void)registerTemplateSource:(id <GXTemplateSourceProtocal>)source {
    if (source && [source conformsToProtocol:@protocol(GXTemplateSourceProtocal)]) {
        NSInteger priority = [source priority];
        if (priority >= 0 && priority <= 99) {
            _isNeedSort = YES;
            NSString *key = [NSString stringWithFormat:@"%ld", priority];
//            GXAssert(![_kvSources objectForKey:key] , @"已经存在相同优先级的数据源,请重新设置数据源优先级");
            [_kvSources gx_setObject:source forKey:key];
        }
    }
}

预期正确的结果

  1. 要么在注释中明确说明priority的上限。debug mode 添加assert
  2. 定义明确的优先级枚举

如果可以的话,添加截图来帮助解释您的问题。

客户端 (请填写如下信息) :

biezhihua commented 1 year ago

@jingcheng1988

biezhihua commented 1 year ago

https://github.com/alibaba/GaiaX/pull/386