Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiMisiukevich authored Jul 29, 2019
1 parent 6c85bac commit cf2ddbf
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,33 +76,34 @@ namespace YourNamespace
**IMPORTANT:** i suggest to NOT use ```[Xaml.XamlCompilation(Xaml.XamlCompilationOptions.Compile)]``` with HotReload. It can cause errors. So, don't enable it for Debug or disable.

### C# Elements reloading
* **AVAILABLE ON ANDROID AND IOS SIMULATORS**.

* First of All add ```--enable-repl``` to iOS additional mtouch arguments for iPhone Simulator:

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

* For Reloading C# view you NEED to mark it with an attribute - **[HotReloader.CSharpVisual]**:
```csharp
[HotReloader.CSharpVisual]
public class CodeContentPage : ContentPage
{
private Color _backColor;

public CodeContentPage(Color backColor)
{
}
}
[HotReloader.CSharpVisual] // Add this attribute
public class CodeContentPage : ContentPage
{
}
```
**NOTE**: BindingContext will be copied automaticaly, but if your view constructor has any parameters, you will have to implement an interface - **ICsharpRestorable**:
```csharp
[HotReloader.CSharpVisual]
public class CodeContentPage : ContentPage
{
private Color _backColor;

public CodeContentPage(Color backColor)
{
_backColor = backColor;
BackgroundColor = backColor;
}
[HotReloader.CSharpVisual]
public class CodeContentPage : ContentPage
{
private Color _backColor;

public object[] ConstructorRestoringParameters => new object[] { _backColor }; //These arguments will be passed in case of reloading
public CodeContentPage(Color backColor)
{
_backColor = backColor;
BackgroundColor = backColor;
}

public object[] ConstructorRestoringParameters => 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.
Expand Down

0 comments on commit cf2ddbf

Please sign in to comment.