@superleapai/flow-ui 2.5.21 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/crm.js CHANGED
@@ -248,17 +248,18 @@
248
248
  }
249
249
 
250
250
  /**
251
- * Notify the CRM that the form was submitted successfully.
252
- * The CRM listens for 'crm:formSubmitSuccess' and can react
253
- * (e.g. close the form, refresh data, show a toast).
251
+ * Register a callback for when the CRM form is submitted successfully.
252
+ * The CRM sends a 'crm:formSubmitSuccess' message after the form saves.
254
253
  *
255
- * @param {Object} [payload]optional data about the submission
254
+ * @param {Function} callbackreceives (payload)
255
+ * @returns {Function} unsubscribe function
256
256
  */
257
- function formSubmittedSuccessfully(payload) {
257
+ function onFormSubmitSuccess(callback) {
258
258
  var bridge = getBridge();
259
- if (bridge && bridge.isConnected()) {
260
- bridge.send("crm:formSubmitSuccess", payload || {});
259
+ if (!bridge) {
260
+ return function () {};
261
261
  }
262
+ return bridge.onMessage("crm:onFormSubmitSuccess", callback);
262
263
  }
263
264
 
264
265
  // ---------------------------------------------------------------------------
@@ -335,8 +336,7 @@
335
336
  global.superleapClient.disconnect = disconnect;
336
337
  global.superleapClient.setLoading = setLoading;
337
338
  global.superleapClient.closeForm = closeForm;
338
- global.superleapClient.formSubmittedSuccessfully =
339
- formSubmittedSuccessfully;
339
+ global.superleapClient.onFormSubmitSuccess = onFormSubmitSuccess;
340
340
  global.superleapClient.toast = toast;
341
341
  global.superleapClient.navigate = navigate;
342
342
  global.superleapClient.getContext = getContext;