小编Rig*_*tti的帖子

如何使用 RootState 修复切片的循环依赖关系?

我最近开始使用redux-toolkit并开始使用createSlice以下他们的文档编写我的减速器。

一个减速器,我们称之为reducerA,导入customAsyncFunction来处理它的回调,这个函数是通过createAsyncThunk它创建的,通过它依次读取RootState调用时thunkApi.getState(),现在的问题RootReducer是导入时,reducerA将被导入生成循环引用。

基本上:RootReducer -> reducerA -> actions -> RootReducer -> ...

下面我尝试简化问题。

// actions.ts file
import { RootState } from "./RootReducer";

export const customAsyncAction = createAsyncAction("myaction", async (_, thunkApi) =>
  const state = thinkApi.getState() as RootState;
  ...
);


// reducerA.ts file
import { customAsyncAction } from "./actions";

const slice = createSlice({
  ...
  extraReducers: {
    [customAsyncAction.fulfilled.toString()]: ... // handles fulfilled action
  }
}); …
Run Code Online (Sandbox Code Playgroud)

typescript redux redux-toolkit

7
推荐指数
3
解决办法
2250
查看次数

列索引顺序 SQLite 创建表

这是我用来创建表的查询

create table site_table(
   _id integer primary key autoincrement,
   name_site text,
   url text,
   login text,
   pass text
);
Run Code Online (Sandbox Code Playgroud)

我打电话Cursor.getColumnNames()并注意到列顺序是id, login, pass, name, url.

所以,如果我想要一个值,我必须通过 index 来获取它Cursor.getString(index)。在我调试之前,我一直在调用错误的索引,但现在我想知道,为什么 SQLite 以这种方式保存?为什么它不遵循我创建的方式id, name_site, url, login and pass

谢谢

sqlite android

5
推荐指数
1
解决办法
2556
查看次数

使用同一对象的其他属性初始化对象属性

我是JS新手。我的问题是:如何使用同一对象的其他属性来很好地初始化对象属性。

例子:

var obj = {
  par1 : 2*2,
  par2 : this.par1
};
Run Code Online (Sandbox Code Playgroud)

谢谢。

javascript object

5
推荐指数
1
解决办法
550
查看次数

标签 统计

android ×1

javascript ×1

object ×1

redux ×1

redux-toolkit ×1

sqlite ×1

typescript ×1