Am using svelte I don't have a lot of info on reac...
# off-topic
h
Am using svelte I don't have a lot of info on react-query. It supports realtime?
a
React-query is just a library to manage data fetching, svelte-query may be the same I don't know. But anyways they have helper functions so you can tell when a query is out of date and it's going to refresh it automatically
Copy code
export function useCreateItem(onsettled=null,onerror=null) {
  const queryClient = useQueryClient();
  const query = async ({data}) => {await supabase.from('items').insert([data])}
  return useMutation('createItem', query, {
    onMutate: async newItem => {
      await queryClient.cancelQueries('useItemsByOwner')
      const previousItems = queryClient.getQueryData('useItemsByOwner')
      queryClient.setQueryData('useItemsByOwner', old => [...old, newItem])
      return { previousItems }
    },
    onError: (err, newTodo, context) => {
      queryClient.setQueryData('useItemsByOwner', context.previousTodos)
      if (onerror) onerror(err);
    },
    onSettled: () => {
      queryClient.invalidateQueries('useItemsByOwner')
      if (onsettled) onsettled();
    },
  })
This piece of code allow me to use supabase to mutate my items table, before mutating the server I will update my cache of the data with the new item (optimistic update) and in the end you can see that I invalidate the query (in the onSettled part) which mean that whatever happen the data is going to be updated with real server data
For sure it's specific to my case, maybe you need realtime for sure but for me this solve the problem and I don't need realtime thanks to this
Of course with applications that are heavily dependant on realtime then realtime queries are needed that's for sure
h
Exactly
Its real time heavy and
Anyway I will check it out
Better than waiting for security to be implemented