You need to pass the name submitted by the user when you dispatch the event form_submitHandler
in RegistrationPage
:
private function form_submitHandler(event:FormEvent):Void
{
if(textInput.text.trim()=="") textInput.errorString="Empty";
else dispatchEvent(new Event(Event.CHANGE));
}
So, you'd create a subclass of Event
, similar to ContactEvent
in stack-navigator-pass-data-between-views
, and dispatch it there instead of new Event(Event.CHANGE)
. I'll leave creating that event subclass up to you. Let's assume that you call it something like RegistrationEvent
.
Then, you need to pass the name from the RegistrationEvent
to the HomePage
, which you'd do by modifying the event map here:
var registrationPage = StackItem.withClass(RegistrationPage.ID, RegistrationPage, [
Event.CHANGE => Push(HomePage.ID)
]);
Similar to stack-navigator-pass-data-between-views
, you'd use NewAction
action to create a custom Push
action that includes passing the data to HomePage
var registrationPage = StackItem.withClass(RegistrationPage.ID, RegistrationPage, [
RegistrationEvent.REGISTER => NewAction((event:RegistrationEvent) -> {
var name = event.name;
return Push(HomePage.ID, (target: HomePage) -> {
target. registeredName = name;
});
})
]);
You'll need to modify HomePage
to add a new property to store the name, which might be called something like registeredName
.
public var registeredName(default, set):String = null;
private function set_registeredName(value:String):String {
if (this.registeredName == value) {
return this.registeredName;
}
this.registeredName = value;
this.setInvalid(InvalidationFlag.DATA);
return this.registeredName;
}
Then, you can access the name in an override of update
in HomePage
.