Mobx未观察到阵列拼接

时间:2019-09-06 19:47:07

标签: javascript arrays react-native mobx mobx-react

我定义了一个从数组中删除项目的动作:

export default class myStore {

  @observable items = [];
  ...
  ...

  @action deleteItem = async (target) => {
    try {
      await backendService.deleteItem(target.id);
      runInAction(() => {
        const targetIndex = this.items.indexOf(target);
        this.items.splice(targetIndex, 1);
      });
    } catch (error) {
      ...
    }
  };

  ...
  ...
}

尽管我将组件设为observer,但在触发其他操作(单击,重命名等)之前,它仍然不会更新列表,在这种情况下,我将能够看到该项目已经删除。

我想念什么吗?

1 个答案:

答案 0 :(得分:2)

尝试以下解决方案:

jpeg_list = os.listdir(SAVE_DIR)

for i in range(len(jpeg_list)):
    aggregate_file = cv2.imread(jpeg_list[i])
    next_img = cv2.imread(jpeg_list[i+1])
    dst = cv2.addWeighted(aggregate_file, 0.5, next_img, 0.5, 0)
    cv2.imshow('dst', dst)