Skip to content

Commit 3aeaf7d

Browse files
authored
feat: adds option to specify custom Reaction (#161)
* feat: adds option to specify custom Reaction * chore: update docker image
1 parent 0da6efe commit 3aeaf7d

File tree

7 files changed

+8427
-9836
lines changed

7 files changed

+8427
-9836
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2.1
22
executors:
33
node8:
44
docker:
5-
- image: mcr.microsoft.com/playwright:bionic
5+
- image: mcr.microsoft.com/playwright:focal
66
environment:
77
NODE_ENV: development
88
NPM_CONFIG_PREFIX: ~/.npm-global

.gitignore

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
/node_modules/
2-
3-
coverage
4-
#Compiler Output
5-
*.tsbuildinfo
6-
*.log
7-
lib
8-
9-
test/**/*.js
10-
test/**/*.js.map
11-
test/**/*.d.ts
12-
test/**/*.d.ts.map
13-
14-
src/**/*.js
15-
src/**/*.js.map
16-
src/**/*.d.ts
17-
src/**/*.d.ts.map
18-
19-
lit-mobx.js
20-
lit-mobx.js.map
21-
lit-mobx.d.ts
22-
lit-mobx.d.ts.map
23-
24-
demo/**/*.js
25-
demo/**/*.js.map
26-
27-
.DS_Store
1+
/node_modules/
2+
3+
/coverage
4+
#Compiler Output
5+
*.tsbuildinfo
6+
*.log
7+
/lib
8+
9+
test/**/*.js
10+
test/**/*.js.map
11+
test/**/*.d.ts
12+
test/**/*.d.ts.map
13+
14+
src/**/*.js
15+
src/**/*.js.map
16+
src/**/*.d.ts
17+
src/**/*.d.ts.map
18+
19+
lit-mobx.js
20+
lit-mobx.js.map
21+
lit-mobx.d.ts
22+
lit-mobx.d.ts.map
23+
24+
demo/**/*.js
25+
demo/**/*.js.map
26+
27+
.DS_Store

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,24 @@ For further examples see the [demo folder](./demo).
8383

8484
NOTE: observables are only hooked for updating the render function if those observables are directly used within the render function. The implementation of this library is such that we essential wrap the render function in an `autorun` block to hook these observables for re-running render. If you wish to response to an observable property to calculate some other result that then itself is used in the render function, then you need to use the regular MobX methods for observability in a property changed callback or some other lifecycle function to setup that observation and the write to a property in your component that is appropriately decorated to drive Lit's regular update cycle.
8585

86+
## Custom Reaction
87+
88+
In some rare cases applications may need to have multiple different major versions of Mobx within a single app. This can lead to issues where the version of mobx used in various places needs to be specifically imported from aliased versions of mobx, e.g. aliasing `mobx 6.x` to `mobx6`.
89+
90+
To help support these cases lit-mobx provides the custom implementation of the MobxReactionUpdate mixin, `MobxReactionUpdateCustom`, that supports taking the `Reaction` constructor as a second argument. This allows the user to define which version of mobx to pass, and ensures that no side effects are caused by lit-mobx importing `mobx` directly.
91+
92+
Example usage:
93+
94+
```typescript
95+
import { MobxReactionUpdateCustom } from '@adobe/lit-mobx/lib/mixin-custom.js';
96+
97+
// import your specific mobx version
98+
import { Reaction } from 'mobx6';
99+
100+
// and pass it to the mixin to create your own mobx lit element base class
101+
class Mobx6LitElement extends MobxReactionUpdateCustom(LitElement, Reaction) {}
102+
```
103+
86104
### Contributing
87105

88106
Contributions are welcomed! Read the [Contributing Guide](./.github/CONTRIBUTING.md) for more information.

0 commit comments

Comments
 (0)