This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cote = require('cote'); | |
const responder = new cote.Responder({ name: 'currency conversion responder' }); | |
const subscriber = new cote.Subscriber({ name: 'arbitration subscriber' }); | |
const rates = { usd_eur: 0.91, eur_usd: 1.10 }; | |
subscriber.on('update rate', (update) => { | |
rates[update.currencies] = update.rate; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cote = require('cote'); | |
const responder = new cote.Requester({ name: 'currency conversion responder' }); | |
const subscriber = new cote.Subscriber({ name: 'arbitration subscriber' }); | |
const rates = { usd_eur: 0.91, eur_usd: 1.10 }; | |
subscriber.on('update rate', (update) => { | |
rates[update.currencies] = update.rate; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subscriber.on('update rate', (update) => { | |
rates[update.currencies] = update.rate; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const subscriber = new cote.Subscriber({ name: 'arbitration subscriber' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cote = require('cote'); | |
const responder = new cote.Responder({ name: 'arbitration API', key: 'arbitration' }); | |
const publisher = new cote.Publisher({ name: 'arbitration publisher' }); | |
const rates = {}; | |
responder.on('update rate', (req, cb) => { | |
rates[req.currencies] = req.rate; | |
cb('OK!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
responder.on('update rate', (req, cb) => { | |
rates[req.currencies] = req.rate; | |
cb('OK!'); | |
publisher.publish('update rate', req); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const publisher = new cote.Publisher({ name: 'arbitration publisher' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
responder.on('update rate', (req, cb) => { | |
rates[req.currencies] = req.rate; // { currencies: 'usd_eur', rate: 0.91 } | |
cb('OK!'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rates = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cote = require('cote'); | |
const responder = new cote.Responder({ name: 'currency conversion responder' }); |
NewerOlder