27 lines
600 B
JavaScript
27 lines
600 B
JavaScript
import { useContext, useEffect } from 'react';
|
|
import GroupChat from '/imports/api/group-chat';
|
|
import { GroupChatContext, ACTIONS } from './context';
|
|
|
|
const Adapter = () => {
|
|
const usingGroupChatContext = useContext(GroupChatContext);
|
|
const { dispatch } = usingGroupChatContext;
|
|
|
|
useEffect(() => {
|
|
const groupChatCursor = GroupChat.find({});
|
|
|
|
groupChatCursor.observe({
|
|
added: (obj) => {
|
|
dispatch({
|
|
type: ACTIONS.ADDED,
|
|
value: {
|
|
groupChat: obj,
|
|
},
|
|
});
|
|
},
|
|
});
|
|
}, []);
|
|
return null;
|
|
};
|
|
|
|
export default Adapter;
|