Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use existing application instance if it exists #42

Closed
wants to merge 1 commit into from
Closed

Use existing application instance if it exists #42

wants to merge 1 commit into from

Conversation

cmeeren
Copy link
Member

@cmeeren cmeeren commented Aug 3, 2018

Fixes #41

Turned out to be a devilishly simple fix. Simply use the existing application instance if it exists. AFAIK this is non-breaking, since there can only be one Application instance per AppDomain, so existing users have not been able to instantiate their own Application instance until now, ensuring that this is an opt-in feature.

With this simple change, users that need application-wide resources or otherwise need to specify an application instance can simply instantiate it before calling the Program functions. For example:

[<EntryPoint;STAThread>]
let main _argv =
  App() |> ignore
  Program.mkSimple init update view
  |> Program.runWindow (MainWindow())

Something like this should probably be added to the documentation and/or a sample.

@cmeeren cmeeren mentioned this pull request Aug 25, 2018
7 tasks
@cmeeren
Copy link
Member Author

cmeeren commented Sep 1, 2018

Closed by #48

@cmeeren cmeeren closed this Sep 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Application must be instantiated before call to window constructor due to resources in App.xaml
1 participant