@nuskin/ns-util 4.1.1 → 4.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-util",
3
- "version": "4.1.1",
3
+ "version": "4.2.0",
4
4
  "baseURL": "/",
5
5
  "main": "src/util.js",
6
6
  "scripts": {
@@ -23,6 +23,7 @@
23
23
  "license": "ISC",
24
24
  "homepage": "https://code.tls.nuskin.io/ns-am/nu-skin-aem/wm/ns-util/blob/master/README.md",
25
25
  "dependencies": {
26
+ "@nuskin/events": "1.0.0-cx16-8326.6",
26
27
  "@nuskin/ns-common-lib": "1.2.3",
27
28
  "@nuskin/nuskinjquery": "2.3.1",
28
29
  "axios": "0.21.1",
@@ -44,7 +45,7 @@
44
45
  ]
45
46
  },
46
47
  "devDependencies": {
47
- "@nuskin/configuration-sdk": "2.0.0",
48
+ "@nuskin/configuration-sdk": "2.2.0",
48
49
  "@nuskin/ns-jsanalyzer": "1.0.1",
49
50
  "axios-mock-adapter": "1.18.2",
50
51
  "babel-cli": "6.26.0",
@@ -1,5 +1,5 @@
1
1
  import nuskin from './namespace.js';
2
- import './event.js';
2
+ import events from './event.js';
3
3
  import mktRegionMapping from './regionMapping.js';
4
4
  import RunConfigService from './runConfigService.js';
5
5
  import axios from 'axios';
@@ -34,7 +34,7 @@ const setRuntimeOverrides = () => {
34
34
  if (shoppingContext && shoppingContext.overrides) {
35
35
  nuskin.configuration = _.merge(nuskin.configuration, shoppingContext.overrides);
36
36
  }
37
- $.setValue(nuskin.events.global.CONFIGURATION_SET);
37
+ events.setValue(nuskin.events.global.CONFIGURATION_SET);
38
38
  return nuskin.configuration;
39
39
  };
40
40
 
@@ -55,7 +55,7 @@ let getConfiguration = (url, country, domain, forceLoad = false, ignoreContext)
55
55
  // config = res;
56
56
  // nuskin.configuration = config;
57
57
  // lastUrl = url;
58
- // $.setValue(nuskin.events.global.CONFIGURATION_SET);
58
+ // events.setValue(nuskin.events.global.CONFIGURATION_SET);
59
59
  // })
60
60
  // .catch(xhr => {
61
61
  // nuskin.configuration = null;
@@ -107,7 +107,7 @@ let getConfiguration = (url, country, domain, forceLoad = false, ignoreContext)
107
107
  lastContext = shoppingContext.context;
108
108
  }
109
109
  //This works here because the configuration ajax calls are synchronous. If we ever switch to async then we need to publish after the ajax call comes back
110
- $.setValue(nuskin.events.global.CONFIGURATION_SET);
110
+ events.setValue(nuskin.events.global.CONFIGURATION_SET);
111
111
  return config;
112
112
  };
113
113
 
package/src/event.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { BroadcastChannel } from 'broadcast-channel';
3
- import '@nuskin/nuskinjquery';
3
+ import nsEvents from '@nuskin/events';
4
4
  import * as _ from 'lodash';
5
5
  import RunConfigUtil from './runConfigUtil.js';
6
6
 
@@ -16,8 +16,8 @@ import RunConfigUtil from './runConfigUtil.js';
16
16
  * (2) Publish the event through the appropriate nuskin.events wrapper function, such as nuskin.events.publishError(nuskin.events.MY_NEW_ERROR);
17
17
  * (3) Subscribe from the code location where you'd like to handle the event: nuskin.events.subscribe( nuskin.events.MY_NEW_ERROR, function(evt) {//handle event});
18
18
  *
19
- * Note that as of now, the wrapper functions for subscribe and publish don't do anything other than route to $.publish()
20
- * and $.subscribe(). But if we use the wrapper functions here we can centralize for adaptability later on.
19
+ * Note that as of now, the wrapper functions for subscribe and publish don't do anything other than route to nsEvents.publish()
20
+ * and nsEvents.subscribe(). But if we use the wrapper functions here we can centralize for adaptability later on.
21
21
  *
22
22
  * Also note that the functions for error event handling are designed to help standardize the transmission of data in
23
23
  * cases such as AJAX request errors. One could just use the jQuery pub/sub functions directly, but then if we need to
@@ -412,7 +412,7 @@ if (!nuskin.events) {
412
412
  * @memberof nuskin.events
413
413
  */
414
414
  function getValue(eventId, eventCallback, doSubscribe) {
415
- $.getValue(eventId, eventCallback, doSubscribe);
415
+ nsEvents.getValue(eventId, eventCallback, doSubscribe);
416
416
  }
417
417
 
418
418
  /**
@@ -424,7 +424,7 @@ if (!nuskin.events) {
424
424
  * @memberof nuskin.events
425
425
  */
426
426
  function setValue(eventId, eventObject) {
427
- $.setValue(eventId, eventObject);
427
+ nsEvents.setValue(eventId, eventObject);
428
428
  }
429
429
 
430
430
  /**
@@ -434,7 +434,7 @@ if (!nuskin.events) {
434
434
  * @memberof nuskin.events
435
435
  */
436
436
  function unsubscribe(eventId, fn) {
437
- $.unsubscribe(eventId, fn);
437
+ nsEvents.unsubscribe(eventId, fn);
438
438
  }
439
439
 
440
440
  /**
@@ -445,7 +445,7 @@ if (!nuskin.events) {
445
445
  * @memberof nuskin.events
446
446
  */
447
447
  function subscribe(eventId, eventCallback) {
448
- $.subscribe(eventId, eventCallback);
448
+ nsEvents.subscribe(eventId, eventCallback);
449
449
  }
450
450
 
451
451
 
@@ -460,7 +460,7 @@ if (!nuskin.events) {
460
460
  function publish(eventId, eventObject = null, fromBroadcast) {
461
461
  const mdata = getMetadata(eventId);
462
462
  if (!mdata || (mdata && mdata.publish)) {
463
- $.publish(eventId, eventObject);
463
+ nsEvents.publish(eventId, eventObject);
464
464
  }
465
465
  // If we need to broadcast and it hasn't broadcasted yet
466
466
  if (mdata && mdata.broadcast && !fromBroadcast) {
@@ -485,7 +485,7 @@ if (!nuskin.events) {
485
485
  * @private
486
486
  */
487
487
  function publishError(eventId, eventObject) {
488
- $.publish(eventId, events.getErrorEventObject(eventObject.messageId ? eventObject.messageId : eventId, eventObject.messageString));
488
+ nsEvents.publish(eventId, events.getErrorEventObject(eventObject.messageId ? eventObject.messageId : eventId, eventObject.messageString));
489
489
  }
490
490
 
491
491
 
@@ -505,7 +505,7 @@ if (!nuskin.events) {
505
505
  *
506
506
  */
507
507
  function publishAjaxErrorEvent(eventId, url, response, messageId, messageString) {
508
- $.publish(eventId, events.getAjaxErrorEventObject(messageId ? messageId : eventId, url, response, messageString));
508
+ nsEvents.publish(eventId, events.getAjaxErrorEventObject(messageId ? messageId : eventId, url, response, messageString));
509
509
  }
510
510
 
511
511
 
@@ -525,7 +525,7 @@ if (!nuskin.events) {
525
525
  * @memberof nuskin.events
526
526
  */
527
527
  function publishAjaxError(eventId, eventObject) {
528
- $.publish(eventId, events.getAjaxErrorEventObject(eventObject.messageId ? eventObject.messageId : eventId, eventObject.url, eventObject.response, eventObject.messageString));
528
+ nsEvents.publish(eventId, events.getAjaxErrorEventObject(eventObject.messageId ? eventObject.messageId : eventId, eventObject.url, eventObject.response, eventObject.messageString));
529
529
  }
530
530
 
531
531