Full page app listener event

Hello.

I need to make full page app of web application(not custom app).
I want when the contact or appointment update, reload full page app or web application.

I tried to full page app but can’t listener event.
The below is the code.

document.addEventListener("DOMContentLoaded", function () {
  app.initialized().then(function (client) {
 window.client = client;
 client.events.on("app.activated", onAppActivate);
  }).catch(handleErr);
});

function onAppActivate() {
  var btn = document.querySelector('.btn-open');
  btn.addEventListener('click', openModal);
  // Start writing your code...

  client.events.on('contact.update', contactUpdate, {intercept: true});
  client.events.on('deal.update', dealUpdate, {intercept: true});
  client.events.on('account.update', accountUpdate, {intercept: true});
}

function openModal() {
  client.interface.trigger(
   'showModal',
    useTemplate('Title of the Modal', './views/modal.html')
  );
}

function useTemplate(title, template) {
  return {
   title,
    template
  };
}

function contactUpdate(data) {
  console.log('==> contactUpdate');
  console.log(data);
}

function dealUpdate(data) {
  console.log('==> dealUpdate');
  console.log(data);
}

function accountUpdate(data){
  console.log('==> accountUpdate');
 console.log(data);
}

How I can listener event in full page app?

Hi @Juyeong_Lee,

Thank you for participating in this community.

I just want to understand you question a lot more clearly. I hope you could help me out here.

From what I understood from your post — Your app observes UI events such as contact update, deal update and account update. When ever those events are observed, you want to reload full page app.

In that case, you can invoke onAppActivate() within the function defn of contactUpdate(..){..} or dealUpdate(..){..} or accountUpdate(..){..}. Did you try something like it? Is my understanding correct?

Hello, @Saif.

Thank you for your reply.
That event listener already in “onAppActive()”, and I tried another way but all not working.
I thinking full page app can’t catch event in contact deal and account.
So, I’ll not develop full page app.
I’ll develop service with serverless app and another web page.

1 Like