Hi, I’m trying to achieve something that might seen as bad practice but I’m trying to add a realm listener in a redux-thunk function. But for now I’m facing problems when I query Item
table as follows
export const getItems = createAsyncThunk("getItems", async (config: any) => {
try {
return await Realm.open(config).then(async (projectRealm) => {
const items = await projectRealm.objects("Item");
let sortedItems = await items.sorted("itemCode");
return await sortedItems.map(async (x: any) => {
return await x;
});
});
} catch (error) {
console.log(error);
throw error;
}
});
and redux actions which will handle the incoming data from Item
to populate the store
extraReducers: (builder) => {
builder.addCase(getItems.fulfilled, (state, { payload }: any) => {
try {
state.push(payload);
console.log(payload);
} catch (error) {
console.log(error);
}
});
},
Expected Results:
Every time when a user logins getItems
will be triggered and retrieve items which have the following data schema types:
itemCode: string,
itemDescription: string,
itemPrice: string,
partition: string
Actual Results:
When i ran console.log(payload)
the type of data I get is confusing and have no clue what I got back: