mirror of
https://github.com/embarklabs/embark.git
synced 2025-03-02 06:10:46 +00:00
Don't import git history of embark-framework/EmbarkJS, simply copy over the sources. Modify `package.json`, etc. re: being situated in the monorepo. Make use of the root babel config but extend with `packages/embarkjs/.babelrc.js`. Build `test/` scripts into `build-test/` and git-ignore `build-test/`. Revise `Blockchain.connect()` so that if the caller supplies a callback then a promise is not returned. Revise tests to test `Blockchain.connect()` usage with and without a callback.
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
let Messages = {};
|
|
|
|
Messages.Providers = {};
|
|
|
|
Messages.registerProvider = function (providerName, obj) {
|
|
this.Providers[providerName] = obj;
|
|
};
|
|
|
|
Messages.setProvider = function (providerName, options) {
|
|
let provider = this.Providers[providerName];
|
|
|
|
if (!provider) {
|
|
throw new Error('Unknown messages provider');
|
|
}
|
|
|
|
this.currentProviderName = providerName;
|
|
this.currentMessages = provider;
|
|
|
|
return provider.setProvider(options);
|
|
};
|
|
|
|
Messages.isAvailable = function () {
|
|
if (!this.currentMessages) {
|
|
return false;
|
|
}
|
|
return this.currentMessages.isAvailable();
|
|
};
|
|
|
|
Messages.sendMessage = function (options) {
|
|
if (!this.currentMessages) {
|
|
throw new Error('Messages provider not set; e.g EmbarkJS.Messages.setProvider("whisper")');
|
|
}
|
|
return this.currentMessages.sendMessage(options);
|
|
};
|
|
|
|
Messages.listenTo = function (options, callback) {
|
|
if (!this.currentMessages) {
|
|
throw new Error('Messages provider not set; e.g EmbarkJS.Messages.setProvider("whisper")');
|
|
}
|
|
return this.currentMessages.listenTo(options, callback);
|
|
};
|
|
|
|
export default Messages;
|