aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/serviceLimit/index.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2019-04-30 15:23:38 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2019-04-30 15:23:38 +0200
commit1bae1dfcbc4a5f590c51103635006198ae6a91d6 (patch)
treec838e9e7e18342c01e3c3b46c8e9ca4b74895e3b /src/features/serviceLimit/index.js
parentUpdate CHANGELOG.md (diff)
downloadferdium-app-1bae1dfcbc4a5f590c51103635006198ae6a91d6.tar.gz
ferdium-app-1bae1dfcbc4a5f590c51103635006198ae6a91d6.tar.zst
ferdium-app-1bae1dfcbc4a5f590c51103635006198ae6a91d6.zip
Enforce service limit
Diffstat (limited to 'src/features/serviceLimit/index.js')
-rw-r--r--src/features/serviceLimit/index.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/features/serviceLimit/index.js b/src/features/serviceLimit/index.js
new file mode 100644
index 000000000..76f996195
--- /dev/null
+++ b/src/features/serviceLimit/index.js
@@ -0,0 +1,33 @@
1import { reaction } from 'mobx';
2import { ServiceLimitStore } from './store';
3
4const debug = require('debug')('Franz:feature:serviceLimit');
5
6export const DEFAULT_SERVICE_LIMIT = 3;
7
8let store = null;
9
10export const serviceLimitStore = new ServiceLimitStore();
11
12export default function initServiceLimit(stores, actions) {
13 const { features } = stores;
14
15 // Toggle serviceLimit feature
16 reaction(
17 () => (
18 features.features.hasServiceLimit
19 ),
20 (isEnabled) => {
21 if (isEnabled) {
22 debug('Initializing `serviceLimit` feature');
23 store = serviceLimitStore.start(stores, actions);
24 } else if (store) {
25 debug('Disabling `serviceLimit` feature');
26 serviceLimitStore.stop();
27 }
28 },
29 {
30 fireImmediately: true,
31 },
32 );
33}