Skip to content

Commit dd1deeb

Browse files
committed
Merge branch 'master' of https://github.com/mrpmorris/Fluxor
2 parents 19e740a + 7308190 commit dd1deeb

File tree

1 file changed

+0
-78
lines changed
  • Source/Tutorials/02-Blazor/02D-ReduxDevToolsTutorial

1 file changed

+0
-78
lines changed

Source/Tutorials/02-Blazor/02D-ReduxDevToolsTutorial/README.md

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -79,84 +79,6 @@ Note that determining the stack trace is an expensive operation.
7979

8080
![](./../../../../images/redux-dev-tools-trace.jpg)
8181

82-
### Controlling JSON options
83-
84-
It is possible to specify which JSON library the Redux Dev Tools Middleware
85-
plugin should use when serializing to / deserializing from the
86-
Redux Dev Tools browser plugin.
87-
88-
By default, `System.Text.Json` and `Newtonsoft.Json` are supported. In both cases,
89-
the action that creates the Options/Settings is passed an `IServiceProvider`.
90-
91-
The following example shows how to use `System.Text.Json` as the
92-
JSON serialization library, and how to specify that you want
93-
it to use `camelCase` property names in the generated JSON.
94-
95-
```c#
96-
services.AddFluxor(o =>
97-
o.ScanAssemblies(typeof(SomeType).Assembly),
98-
o.UseReduxDevTools(rdt =>
99-
{
100-
rdt.UseSystemTextJson(_ =>
101-
new System.Text.Json.JsonSerializerOptions
102-
{
103-
PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase
104-
}
105-
);
106-
}
107-
)
108-
);
109-
```
110-
111-
The following example shows how to use `Newtonsoft.Json` to achieve
112-
the same goal.
113-
114-
```c#
115-
services.AddFluxor(o =>
116-
o.ScanAssemblies(typeof(SomeType).Assembly),
117-
o.UseReduxDevTools(rdt =>
118-
{
119-
rdt.UseNewtonsoftJson(_ =>
120-
new Newtonsoft.Json.JsonSerializerSettings
121-
{
122-
ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver
123-
{
124-
NamingStrategy = new Newtonsoft.Json.Serialization.CamelCaseNamingStrategy()
125-
}
126-
}
127-
);
128-
}
129-
)
130-
);
131-
```
132-
133-
#### Other JSON libraries
134-
135-
Although only `System.Text.Json` and `Newtonsoft.Json` are supported by default, it
136-
is possible to have the Redux Dev Tools middleware use any library of your choice.
137-
138-
This is achieved by creating a class that implements
139-
`Fluxor.Blazor.Web.ReduxDevTools.IJsonSerialization`, and then registering it as
140-
the implementor of that interface udring the Dependency Injection phase.
141-
142-
```c#
143-
// JSON library adapter class
144-
public class MyJsonLibAdapter : IJsonSerialization
145-
{
146-
public object Deserialize(string json, Type type) =>
147-
MyJsonLib.DeserializeObject(json, type);
148-
149-
public string Serialize(object source, Type type) =>
150-
MyJsonLib.SerializeObject(source, type);
151-
}
152-
```
153-
154-
```c#
155-
// Service bootstrapper
156-
services.AddFluxor(...etc...);
157-
services.AddScoped<MyJsonLibAdapter, IJsonSerialization>();
158-
```
159-
16082
[ReduxDevToolsLink]: https://github.com/zalmoxisus/redux-devtools-extension
16183
[ChromePluginLink]: https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en
16284
[FirefoxPluginLink]: https://addons.mozilla.org/en-GB/firefox/addon/reduxdevtools/

0 commit comments

Comments
 (0)