index.js 454 B

123456789101112131415161718192021222324
  1. const data = require('./mock-data')
  2. const LATENCY = 16
  3. export function getAllMessages (cb) {
  4. setTimeout(() => {
  5. cb(data)
  6. }, LATENCY)
  7. }
  8. export function createMessage ({ text, thread }, cb) {
  9. const timestamp = Date.now()
  10. const id = 'm_' + timestamp
  11. const message = {
  12. id,
  13. text,
  14. timestamp,
  15. threadID: thread.id,
  16. threadName: thread.name,
  17. authorName: 'Evan'
  18. }
  19. setTimeout(function () {
  20. cb(message)
  21. }, LATENCY)
  22. }