Skip to content

Commit aa970ff

Browse files
Update README.md
1 parent 844e99a commit aa970ff

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ namespace YourNamespace
8282

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

85-
```
86-
**NOTE**: BindingContext will be copied automaticaly, but if your view constructor has any parameters, you will have to implement an interface - **ICsharpRestorable**:
85+
**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[] { }**:
8786
```csharp
8887
[HotReloader.CSharpVisual]
8988
public class CodeContentPage : ContentPage
@@ -96,15 +95,15 @@ public class CodeContentPage : ContentPage
9695
BackgroundColor = backColor;
9796
}
9897

99-
public object[] ConstructorRestoringParameters => new object[] { _backColor }; //These arguments will be passed in case of reloading
98+
object[] HotReloadCtorParams => new object[] { _backColor }; //These arguments will be passed in case of reloading
10099
}
101100
```
102101

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

105104
### Additional Setup / Troubleshooting
106105

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

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

143-
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.
142+
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.
144143

145144
```csharp
146-
public partial class MainPage : ContentPage, IReloadable
145+
public partial class MainPage : ContentPage
147146
{
148147
public MainPage()
149148
{
150149
InitializeComponent();
151150
}
152151

153-
public void OnLoaded() // Add logic here
152+
void OnHotReloaded() // Add logic here
154153
{
155-
//label.Text = "I'm loaded again";
154+
label.Text = "I'm loaded again";
156155
}
157156
}
158157
```

0 commit comments

Comments
 (0)