Load Contexthub on conditional basis

Avatar

Avatar
Validate 1
Level 1
yashaswidotiya
Level 1

Likes

0 likes

Total Posts

13 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
yashaswidotiya
Level 1

Likes

0 likes

Total Posts

13 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
yashaswidotiya
Level 1

19-05-2020

Hi All,

 

I want to load custom contexthub store on basis of some condition and for that, I have used apply method while registering the storeCandidate. The issue here is that I am getting "no suitable store Implementation found for ...." if condition fails. 

Is there any way that I can prevent these error from coming ?

Sample Code:- 

contextHub.Utils.storeCandidates.registerStoreCandidate(
"VariableName",
"contexthub.storeName",
0,

function(){return false};
);

 

Error message -- No suitable store implementation found for type: contexthub.storeName

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

646 likes

Total Posts

607 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

646 likes

Total Posts

607 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
BrianKasingli
MVP

19-05-2020

@yashaswidotiya,

Sure, you can do this with a JavaScript condition block before you run the "registering the store candidate".

 

   function registerStoreCandidate() {
      if (canRegisterStoreCandidate()) {
        contextHub.Utils.storeCandidates.registerStoreCandidate(
        "VariableName",
        contexthub.storeName,
        0)
      }
   }

   function canRegisterStoreCandidate(){
     // ...someLogicReturnsBoolean;
     // example: returns true if window.contexthub && window.contexthub.storeName both are not empty or undefined.
     return window.contexthub && window.contexthub.storeName;
   };

 

 

 

Answers (0)