我最近开始使用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) 这是我用来创建表的查询
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?
谢谢
我是JS新手。我的问题是:如何使用同一对象的其他属性来很好地初始化对象属性。
例子:
var obj = {
par1 : 2*2,
par2 : this.par1
};
Run Code Online (Sandbox Code Playgroud)
谢谢。