WhileTrue

Hi All,

I’m updated fuse to latest version. But appear Problem with me

in file XXX.ux

in file XXX.js
var scrapeed = Observable(false);

in action I need :
scrapeed.value = true;

module.exports = {
scrapeed}

I’ve made sure that the value turns out scrapped from false to true .
but don’t raise “RaiseUserEvent” !

ALL of ( whiletrue , whilestring ) no longer works after downloading the latest update version of Fuse.

Please Help me to solve this problem ?

Regards,

.ux

		<Panel  Padding="10" Dock="Right" HitTestMode="LocalBoundsAndChildren" >
			<mifIcon  FontSize="25" TextColor="#000" Value="&#xE5CD;" />
			
			<WhilePressed>
				<Change cloose_btn_buyconfirm.Color="#f1f1f1" Duration="0.35" Easing="BackOut"/>
			</WhilePressed>
			<Clicked>
				<RaiseUserEvent EventName="hide_scrpe_confirm_card_event" />
			</Clicked>
			<Rectangle ux:Name="cloose_btn_buyconfirm" Color="#fff" CornerRadius="5" Layer="Background"></Rectangle>
		</Panel>
		<sep Layer="Background" Alignment="Bottom"  Color="#dcdcdc"/>
	</Grid>

	<StackPanel  Padding="5,5,5,20" Margin="0,10,0,0" ItemSpacing="10">
		<notoRightGray Alignment="Center" TextAlignment="Center" TextWrapping="Wrap" TextColor="#9c9c9c"  FontSize="14" Value="Are you sure to scrape this card ?" />
		<sep  Color="#dcdcdc"/>
		<notoRightGray Alignment="Center" TextAlignment="Center" TextWrapping="Wrap" TextColor="#9c9c9c"  FontSize="15" Value="Enter Number of Cards" />

		<Grid CellSpacing="10" Alignment="Center" Columns="auto,50,auto">
							<Circle Clicked="{decrease_quantity}" HitTestMode="LocalBoundsAndChildren" ux:Name="decrease_btn" Width="35" Height="35" Color="#9694a1" >
								<mifIcon Alignment="Center" FontSize="20" TextColor="#fff" Value="&#xE15B;" />
								<DropShadow Size="3" Distance="1" Spread="0.05" Color="#aaa" Angle="90" />
								<WhilePressed>
									<Change decrease_btn.Color="#6a6874" Duration="0.35" Easing="BackOut"/>
								</WhilePressed>
							</Circle>
							
							<TextInput  InputHint="Phone"  PlaceholderColor="#000" Font="noto" Margin="0,10,10,0"  TextColor="#000" Alignment="Center" TextAlignment="Center" FontSize="19" Value="{number_card_scrape}" >
			<WhileString Test="IsEmpty">
				<Text TextColor="#9c9c9c" TextAlignment="Center" FontSize="22" Alignment="Center">1</Text>
			</WhileString>
		</TextInput>

							<Circle Clicked="{increase_quantity}" HitTestMode="LocalBoundsAndChildren" ux:Name="add_btn" Width="35" Height="35" Color="#9694a1" >
								<mifIcon Alignment="Center" FontSize="20" TextColor="#fff" Value="&#xE145;" />
								<DropShadow Size="3" Distance="1" Spread="0.05" Color="#aaa" Angle="90" />
								<WhilePressed>
									<Change add_btn.Color="#6a6874" Duration="0.35" Easing="BackOut"/>
								</WhilePressed>

							</Circle>
		</Grid>



		


		<sep  Color="#dcdcdc"/>
	</StackPanel>
	
	<StackPanel >
		<Grid Columns="1*" >
			<Panel Padding="10,17" HitTestMode="LocalBoundsAndChildren" >
				<Rectangle Color="#fff" CornerRadius="0,0,5,5" Layer="Background" ux:Name="send_numberr_buy_btn" />
				<notoRightGray Alignment="Center" TextColor="#481251"   Value="{scrapeed} +Submit" />
				<WhilePressed>
					<Change send_numberr_buy_btn.Color="#f1f1f1" Duration="0.5" Easing="CircularInOut"/>
				</WhilePressed>
				<Clicked>
					<Callback Handler="{scrape}"/>

				</Clicked>

				<WhileTrue Value="{scrapeed}">
					<RaiseUserEvent EventName="hide_scrpe_confirm_card_event" />
					
				</WhileTrue>

				
				

			</Panel>
			
		</Grid>
	</StackPanel>
	</WhileFalse>
	<WhileTrue Value="{scrapeing}">
        <Text ux:Name="imgbuy1u2" TextAlignment="Center" FontSize="20" Margin="0,20,0,20" TextColor="#999" Font="fa" Alignment="Center" Value="&#xf110;"></Text>
        <Spin Target="imgbuy1u2" Frequency="0.5"/>
    </WhileTrue>
	<Rectangle   CornerRadius="5" Color="#fff" Layer="Background">
</Rectangle>
<DropShadow Size="3" Distance="2" Spread="0.05" Color="#444" Angle="90" />	
</StackPanel>

=========
.js

var scrapeed = Observable(false);

function scrape() {

scrapeed.value = false;
scrapeing.value = true;




fetch(api + "method/ash7anly.api.scrape_?number_card_scrape=" + number_card_scrape.value + "&card=" + selected_card + "&sid=" + router.sid, {
    method: 'GET',
    body: null
}).then(function(response) {
    console.log(JSON.stringify(response));
    scrapeing.value = false;

    if (response.ok) {
        
         scrapeed.value = true;
        return response.json();

    } else {
        scrapeed.value = false;
    }
}).then(function(responseObject) {
  

});

}

function hide_scrpe_confirm_card_model() {
show_scrpe_confirm_card.value = false;
}

You put the set value after return :sweat_smile:

the code the be

    if (response.ok) {

         scrapeed.value = true;
        return response.json(); // this line should be the last
    } else {
        scrapeed.value = false;
    }

Also, are you sure that your response contains ok value ?

Hi Ahmed,

No this has happened just when I copied an pasted my code here and remove not necessary code.
Surely this is self-evident : ) !
I put
“scrapeed.value = true;” before return . And I sure response contains ok.

Plus I put this after :
.then(function(responseObject) {
console.log(JSON.stringify(responseObject));

and here log my correct resopnse.
Here I put
" scrapeed.value = true;"
and in .ux apprare TRUE value Correctly . and print to me true .
My problem not here :frowning:

My problem is :
After scrapeed value become True . Any event inside “whileture” don’t raise it :frowning:

Like this .

Do you understand what I mean?
Thanks for reply and hope help me now.

Also important note,
Not only this function, In everywhere I used “whileture”.

Unfortunately, That All my code run with this problem just after I updated Fuse to the lastest version.

Before updated. All code runs correctly.

file

See Scrapeed value printed beside “Submit”. This is correct. but when value become True any event in ( Whiletrue for this variable) don’t raise :frowning:

if you’d like to raise an event you have to use the following code from JS and WhileTrue will never fire :wink:

hide_scrpe_confirm_card_event.raise();

only this code is needed after/before the scrapeed.value = true

Best,
Ahmad

Thanx Ahmad, but I need to do it in WhileTrue “.ux” Not in JS :frowning:
Here :

 <WhileTrue Value="{scrapeed}">
            <RaiseUserEvent EventName="hide_scrpe_confirm_card_event" />
  </WhileTrue>

and

<OnUserEvent EventName="hide_scrpe_confirm_card_event" Handler="{hide_scrpe_confirm_card_model}"/>

Because in case I will use it in " .JS", I will have to rework a lot :frowning:

Why “RaiseUserEvent” don’t work ??

No way to raise event without method “raise” in you case

RaiseUserEvent can be called from Triggers types only, not while-* family

https://docs.fusetools.com/fuse/triggers/trigger.html

Best

Hi Ahmed,

No, you can do it. Look at this example I do it and try it.
RaiseUserEvent can be called from WhileTrue.

The code attached Here :
https://drive.google.com/file/d/1y_pp9GERBlxNzVOaKsNtBF_6mUAcs7CW/view?usp=sharing

But my problem seems at the structure of paging & Navigator & where I put userEvent.

Best,

Yes, you are right

But its not the correct way as the WhileTrue is not intended to fire events :wink:

I guess that you have fixed your problem by using hide_scrpe_confirm_card_event.raise()

Cheers!

Unfortunately, This is "hide_scrpe_confirm_card_event.raise() " don’t solve my problem.

Thanks for reply Ahmad