20 lines
526 B
TypeScript
20 lines
526 B
TypeScript
import { ActionTree } from "vuex";
|
|
import { AppState } from "./types";
|
|
|
|
const actions: ActionTree<AppState, AppState> = {
|
|
// Add one or more sources
|
|
addSources({ commit, dispatch }, sources: EventSource[]) {
|
|
// Commit to state immediately
|
|
commit("appendSources", sources);
|
|
// Start fetching from each new source
|
|
sources.forEach(x => dispatch("fetchFromSource", x.url));
|
|
},
|
|
|
|
// Fetch events from a source url
|
|
async fetchFromSource({ commit }, url: string) {
|
|
//TODO
|
|
}
|
|
};
|
|
|
|
export default actions;
|