Search code examples
javascriptreactjsspark-ar-studio

Imperative JS to Reactive JS - "if statement" sparkAR


I need some help regarding Reactive JS and "if statement" I do not know how to implement a simple code in Reactive JS something like thisin Spark AR:

if( boolvalue=true)
 {
 vidTex.url = "https://yourvideo";
 }
 else 
 {
  vidTex.url = "";
 }

I found a piece of code done in for Spark Reactive JS like this:

   vidTex.url = Reactive.val(""); // Stop
   vidTex.url = Reactive.val("https://yourvideo"); // Play

But I do not know how to implement the if bool true?

Help


Solution

  • You can use the ternary conditional operator for that:

    vidTex.url = Reactive.val(boolvalue ? "https://yourvideo" : "")