// coreServices.ts
import { getCompositeStore } from './compositeStores';

export const coreServices = {
    updateComposite: (mappings: Record<string, string>) => {
        for (const [mappingString, value] of Object.entries(mappings)) {
            const [storeID, key] = mappingString.replace('@', '').split(':');
            const store = getCompositeStore(storeID);
            store.update(storeData => {
                storeData[key] = value;
                return storeData;
            });
        }
    },
    subscribeComposite: (mappingString: string) => {
        const [storeID] = mappingString.replace('@', '').split(':');
        const store = getCompositeStore(storeID);
        return store;
    },
    testAlert: () => {
        alert("core service alert")
    }
};
