From 6b74877d016d08b5b4e7e9dff8c6057d0a61e5fc Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Sat, 9 Sep 2017 00:15:19 +0700 Subject: [PATCH] Implement and use pymStorage --- client/coral-framework/services/storage.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/coral-framework/services/storage.js b/client/coral-framework/services/storage.js index 91ff10680..11aa5df98 100644 --- a/client/coral-framework/services/storage.js +++ b/client/coral-framework/services/storage.js @@ -87,14 +87,15 @@ export function createPymStorage(pym) { /** * Listens to `pym` and relay storage requests to `storage`. * This is the counterpart of `createPymStorage`. - * @param {string} pym pym - * @return {Object} storage + * @param {Object} storage storage to perform requests on + * @param {Object} pym pym to listen to storage requests + * @param {string} prefix namespace requests by prepending a prefix to the keys */ -export function connectStorageToPym(storage, pym) { +export function connectStorageToPym(storage, pym, prefix = 'talkPymStorage:') { pym.onMessage('pymStorage.request', (msg) => { const {id, method, parameters} = JSON.parse(msg); const {key, value} = parameters; - const prefixedKey = `talkPymStorage:${key}`; + const prefixedKey = `${prefix}${key}`; // Variable for the method return value. let result;