Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi team just wondering how we'd do the equivalent in v8? I'm trying to port the react app demo to v8
I can't seem to find in the documentation the equivalent composition or identifying where in the lifecycle certain things are. In this instance what would the equivalent of OnApplicationStarted be?
public class UmbracoReactStartup : IApplicationEventHandler
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
// Register custom default controller
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
// This project uses dependency injection
// Read more about umbraco and dependency injection here:
var umbracoContext = umbracoApplication.Context.GetUmbracoContext();
var builder = new ContainerBuilder();
var umbracoHelper = new Umbraco.Web.UmbracoHelper(umbracoContext);
// Register our controllers from this assembly with Autofac
// Register controllers from the Umbraco assemblies with Autofac
// Register the types we need to resolve with Autofac
// Set up MVC to use Autofac as a dependency resolver
var container = builder.Build();
// And WebAPI
GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
The ApplicationEventHandler has gone in v8. Instead a new concept has been introduced which is composing. This is made up of a Composer and Components.
The documentation is reasonable on this so I'd give this a read. It should help you update your code for v8.
I still can't see based on the docs what the equivalent to OnApplicationStarted is?
I believe you'll want the initialize function of a Component and you'll want to use an IUserComposer as the base for your composer class. There are 3 types of composer and that is generally the one to use.
This blog post might help, there are 2 others on this blog about components and composers as well
Hope it helps
Thanks Nik that helped a lot :)
Trying to get umbraco and react to work together man it is a nightmare
Actually it looks like with v8 dependency injection I shouldn't need the previous code at all :)
So all the above code gets ripped out and replaced with:
public class UmbracoReactStartupComposer : IUserComposer
public void Compose(Composition composition)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted