Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiMisiukevich authored Apr 14, 2020
1 parent 844e99a commit aa970ff
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ namespace YourNamespace

![alt text](https://github.com/AndreiMisiukevich/HotReload/blob/master/files/enable_repl.png)

```
**NOTE**: BindingContext will be copied automaticaly, but if your view constructor has any parameters, you will have to implement an interface - **ICsharpRestorable**:
**NOTE**: BindingContext will be copied automaticaly, but if your view constructor has any parameters, you will have to define a property **object[] HotReloadCtorParams => new object[] { }**:
```csharp
[HotReloader.CSharpVisual]
public class CodeContentPage : ContentPage
Expand All @@ -96,15 +95,15 @@ public class CodeContentPage : ContentPage
BackgroundColor = backColor;
}

public object[] ConstructorRestoringParameters => new object[] { _backColor }; //These arguments will be passed in case of reloading
object[] HotReloadCtorParams => new object[] { _backColor }; //These arguments will be passed in case of reloading
}
```

* ViewModels (BindingContext) can be updated as well. No need to to mark them with any attribute.

### Additional Setup / Troubleshooting

0) If you want to disable HotReload for Release mode, follow instructions here https://github.com/AndreiMisiukevich/HotReload/issues/115#issuecomment-522475773
0) If you want to disable HotReload for Release mode, follow instructions here https://github.com/AndreiMisiukevich/HotReload/issues/115#issuecomment-524545788

1) Your device/simulator/emulator will be discovered automatically. (**IMPORTANT**:
Make sure your PC/Mac and device/emulator are in the same local network.)
Expand Down Expand Up @@ -140,19 +139,19 @@ var port = info.SelectedDevicePort;
var addresses = info.IPAddresses;
```

4) If you want to make any initialization of your element after reloading, you should implement **IReloadable** interface. **OnLoaded** will be called each time when element is created (constructor called) AND element's Xaml updated. So, you needn't duplicate code in constructor and in **OnLoaded** method. Just use **OnLoaded** then.
4) If you want to make any initialization of your element after reloading, you should define a method **void OnHotReloaded ()**. It will be called each time when element's content (xaml/code) updated.

```csharp
public partial class MainPage : ContentPage, IReloadable
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}

public void OnLoaded() // Add logic here
void OnHotReloaded() // Add logic here
{
//label.Text = "I'm loaded again";
label.Text = "I'm loaded again";
}
}
```
Expand Down

0 comments on commit aa970ff

Please sign in to comment.