The Base Service is used for extending other services. Best used for Single page applications
Non Available
import { BaseService, HttpFetch } from '@hingejs/services'
class MessagesService extends BaseService {
constructor() {
super()
}
getAll() {
const URL = 'endpoint-url' // Must be a valid URL
new HttpFetch().get(URL).subscribe({
error: this.notifyError.bind(this),
next: async payload => {
if (this._isNewPayload(payload)) {
this._payload = payload
this._mutatedPayload = await this._modelPayload(payload)
}
this.announcePayload()
},
})
}
/* async can be used for a promise.all etc. */
async _modelPayload(payload) {
const id = msg.messageID
const title = msg.messageSummary
return {...msg, id, title}
}
}
export default new MessagesService()