How to transfer data between apps using app designer

조회 수: 8 (최근 30일)
Ho Nhu Y Nguyen
Ho Nhu Y Nguyen 2016년 6월 16일
댓글: TADA 2021년 7월 27일
Hello,
I am working on APP1 which has a parameter x, I open APP2 by a button in APP1 and change x (which I already transfer to APP2 from APP1) in APP2.
How can I update x in APP1 when I close APP2 and come back to APP1?
I tried to put in APP2CloseRequest: APP1.x = app.x but seems it doesnt work
Thanks
  댓글 수: 3
Juan José Jiménez
Juan José Jiménez 2020년 12월 14일
Hello, I have the same question, ho did you pass X from app1 to app2? I'm looking for this answer!
Leonor Vieira Dias
Leonor Vieira Dias 2021년 2월 10일
Hello,
Could you explain how you got the data from the appA to go to the appB please?
Thanks

댓글을 달려면 로그인하십시오.

답변 (2개)

TADA
TADA 2019년 6월 16일
The simplest solution would be to couple the two apps. When you open app B send the object of app A to it. Then when app B updates x, it can update the property of app A.
A more robust solution would be to uncouple the two apps and add a mediator class. The mediator knows both app A and app B. It passes all the data between the two back and forth. Both apps don't need to know each other, only the mediator.
The reason I say this implementation is more robust is because tomorrow you may need app A to communicate with a third class instead of app B for some specific functionality. In that case you don't need to change app A, only the mediator class.
  댓글 수: 4
Noah Griffiths
Noah Griffiths 2021년 7월 27일
Hi @TADA,
Wanted to thank you for this example and explanation as it promotes good coding practises. Global/properties sends shivers down my spine so when MATLAB's own documents recommends them I'm immedaitely searching for another solution. Thanks again!
TADA
TADA 2021년 7월 27일
cheers Noah,
I know what you mean, globals give me an allergic reaction

댓글을 달려면 로그인하십시오.


sam0037
sam0037 2016년 6월 23일
Hi,
You can use public properties as explained in the link below to share data between apps. And you can add a closeRequestFcn using the Callback button in the Editor tab of the APPDESIGNER window. Remember to add "delete(app)" in the closeRequestFcn or else the app wont close. I have attached a sample APP to illustrate the above. Run the SendData app which sends the data to RecvData app. Hope this helps.
  댓글 수: 3
Wouter
Wouter 2017년 4월 5일
Ho Nhu Y Nguyen did you already achieved this? I stubmle upon your topic now namely and am also wondering how to implement this behavior. Can you maybe share your findings if you have any?
Ho Nhu Y Nguyen
Ho Nhu Y Nguyen 2017년 4월 25일
Hi Wouter, sorry I couldn't find the solution and currently not working on this.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by