I have a question about prism. I have the main app with ViewModel and a module with business logic. I have set up events in the module for properties that I want to be updated in the main apps ViewModel. On ViewModel load, I subscribe to all the events that are in the Module. I want to get those initial values of the in those properties when they got published on the Module Initialization but I am not sure how to do that. Could someone help me understand how it's supposed to be done?
You cannot receive events that were published before you subscribed. But you should have a service that provides the current values, anyway, so just inject it into the view model and get the initial values from there.
Related
I want to create event to track form input in my website form. For example someone types in name section, phone sectio or email I want to see that as event in my GA4 account. But I couldn't manage to create triger and event from tag manager. Any tips guys?
I created additional variables threw tag manager. But couldn't create trigger.
GTM's best practices advice not to do so-called DOM scraping. The proper solution here would be you asking your front-end developers to push dataLayer events for which you would be listening from GTM. This way, when things change on the front-end, the developers can effortlessly move the tracking to a new form, or a new field.
In some cases, inferior tracking methods must be used, however. In this case, you would want to deploy a custom HTML, which would be a <script> tag in your DOM deploying event listeners on form field interactions. The callbacks of the listeners would deploy dataLayer events with payloads containing whatever else you need to know about the interactions.
After you deploy the listeners and confirm that the callbacks work as you want, you make custom event triggers, indicating your event names from the dataLayer pushes. You can make dataLayer Variables to declare used datapoints in the DL events and use the new variables in your tags.
I'm quiet new to Xamarin.Forms.
This is to clear a doubt.
Is it possible to update view using Messaging Center in Xamarin.Forms ?
The MessagingCenter is a centralized messaging service, meaning you subscribe to it, and other places raise events to it.
What you do when you receive an event is whatever you want. You can use it to update the View if you want but normally its used to update the Model and the INotifyPropertyChanged event notifies the view of any properties that have changed.
This blog article may help further.
http://www.xamarinhelp.com/messenger-service-day-7/
I need to perform an action after switching to a view.
The first time you switch to a view 'activate' and then 'compositionComplete' is called.
After that only 'activate' is called.
It would appear that 'activate' is called before the view has finished being displayed and this is causing issues with a JavaScript control I'm using (Bing Maps V7).
I've been using Hooking Lifecycle Callbacks as a reference but there doesn't appear to be a suitable callback to hook in to.
Is there another event or approach I can use to tell when the DOM has finished changing to the view?
It sounds as though your module is a singleton instead of an instance. Is that true? If you create an instance-based module, the module will be created anew each time it's activated. That will cause the compositionComplete to re-execute.
The activate handler is good for preparing data that will ultimately be displayed in the view. compositionComplete is best for handling matters that depend on a fully-constructed DOM.
We use Bing Maps AJAX v7 as well, and I've always placed it in an instance-based module.
To create an instance-based module, if you're not familiar, make sure your viewmodel returns a constructor function instead of an object literal.
Have you tried placing the Bing initialization in attached? Or creating a custom binding for it? Any third party libraries i use will always be initialized in attached, and if its something i want to use more than once, ill either create a custom binding for it or create a widget.
I have a custom panel with a couple of components, eg. a button and a text box.
Once the button is clicked I would like custom panel that is also the parent panel receives the event and decides what to do, like call setText on the textbox.
Is it possible to achieve this using an eventbus ?
This means that the child components need not handle their event and then relay it.
I don't know the exact classes and how they work together. But sure you could use the GWT EventBus to achieve this. Fire an event in your button class and handle this event in your custom panel. You can google or find related answers here on stackoverflow.
I think this answer will help you: How to use the GWT EventBus
It's pretty simple to fire events and handle this events in other classes in your application.
I am trying to use MVVM light messaging to send a value from one page to another during Navigation (for example, send the id of an item that was selected to an edit page). So the list page's viewmodel sends a message and then sends a navigation message to the view which redirects to the edit page. The edit page's viewmodel gets created only when the navigation to the page happens. So when I register for this event in the edit page viewmodel, I never get the message? What is the best solution for this?
Thanks in advance.
Your best solution would be to use the querystring instead of messaging. If you don't use the querystring, you'll have to deal with situations like the application being deactivated (tomestoned), then the user clicking "back" and your application loads the second page without receiving the message.
However, if you want to continue down this path, you can modify your ViewModelLocator such that your page's ViewModel is created immediately (in ctor for instance) instead of as needed. Since the ViewModelLocator is created as soon as your App.xaml is loaded, you know that any view models will be created immediately. As long as your view model is registering for messages in it's constructor it should receive the message.