Why my cloud application failed to display manipulate element correctly?

7

3

I have:

Fence[content_, length_] := Column[{
   Grid[Partition[Characters[content], UpTo[length]]],
   Grid[{Select[
      Flatten[Transpose[
        PadRight[
         Partition[Characters[content], 
          UpTo[length]], {Ceiling[Length[Characters[content]]/length],
           length}, "@@"]]], # != "@@" &]}]
   }]
Mani[content_] := 
 Manipulate[Fence[content, x], {x, 1, Length[Characters[content]], 1}]

Then test it in my desktop Mathematica and everything goes well:

enter image description here

So I deploy:

CloudDeploy[Mani["0123456789"], Permissions -> "Public"]
CloudObject["https://www.wolframcloud.com/objects/ea1707d8-8c50-4926-bfad-207c5c1c1430"]

But it seems doesn't evaluate my function(Fence):

enter image description here

Sayakiss

Posted 2016-01-24T08:49:06.340

Reputation: 839

Answers

8

Documentation and Details ans Options section for CloudDeploy are saying:

CloudDeploy[expr,...] automatically deploys all definitions needed to evaluate expr, much like CloudSave.

and as we can see, it's not the case here. Or, it's a feature of Manipulate which boxes definitions are got by FrontEnd so maybe evaluation doesn't apply here.

At the end, you can force them to be remembered by using SaveDefinitions:

Mani[content_] :=  Manipulate[
  Column@{Fence[content, x], DownValues@Fence}, 
  {x, 1, Length[Characters[content]], 1}, 
  SaveDefinitions -> True
]

enter image description here

Kuba

Posted 2016-01-24T08:49:06.340

Reputation: 129 207

Thanks! I find you changed my code a little(Looks cleaner than mine). Could you please post it in your answer? – Sayakiss – 2016-01-24T09:11:32.090

@Sayakiss I only added Column with Fence definitions for preview. – Kuba – 2016-01-24T09:16:01.860

I find my cloud app is very slow, how to optimize my code to get an more fluent app? – Sayakiss – 2016-01-24T09:16:04.157

@Sayakiss You can't, each time something is meant to be updated it has to call cloud and send results to you. – Kuba – 2016-01-24T09:16:56.990

1It's really disappointing... I think I should deploy a simple HTML page with a single JavaScript to do that task.. – Sayakiss – 2016-01-24T09:19:16.970

@Sayakiss you are not the only one who feels this way. WRI cloud development team is working on allowing some things to be done client side but this was mentioned 1.5 year earlier and a base cloud is still beta so I'm not expecting this to be anywhere soon. – Kuba – 2016-01-24T09:22:31.190

Really thanks for providing that information kindly! – Sayakiss – 2016-01-24T09:26:18.370