File tree Expand file tree Collapse file tree
packages/polling-controller Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## [ Unreleased]
99
10+ ### Added
11+
12+ - Add ` BlockTrackerPollingDataService ` and ` StaticIntervalPollingDataService ` mixins for integrating the polling pattern in data services
13+
1014## [ 16.0.8]
1115
1216### Changed
Original file line number Diff line number Diff line change 5252 },
5353 "dependencies" : {
5454 "@metamask/base-controller" : " ^9.1.0" ,
55+ "@metamask/base-data-service" : " ^0.1.3" ,
5556 "@metamask/network-controller" : " ^34.0.0" ,
5657 "@metamask/utils" : " ^11.11.0" ,
5758 "@types/uuid" : " ^8.3.0" ,
Original file line number Diff line number Diff line change 11import { BaseController } from '@metamask/base-controller' ;
2+ import { BaseDataService } from '@metamask/base-data-service' ;
23import type {
34 NetworkClientId ,
45 NetworkClient ,
@@ -103,3 +104,13 @@ export const BlockTrackerPollingController = <
103104 BlockTrackerPollingControllerMixin < typeof BaseController , PollingInput > (
104105 BaseController ,
105106 ) ;
107+
108+ export const BlockTrackerPollingDataService = <
109+ PollingInput extends BlockTrackerPollingInput ,
110+ // The return type is inferred from the class defined inside the function
111+ // scope, so this can't be easily typed.
112+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
113+ > ( ) =>
114+ BlockTrackerPollingControllerMixin < typeof BaseDataService , PollingInput > (
115+ BaseDataService ,
116+ ) ;
Original file line number Diff line number Diff line change 11import { BaseController } from '@metamask/base-controller' ;
2+ import { BaseDataService } from '@metamask/base-data-service' ;
23import type { Json } from '@metamask/utils' ;
34
45import {
@@ -96,3 +97,11 @@ export const StaticIntervalPollingController = <PollingInput extends Json>() =>
9697 StaticIntervalPollingControllerMixin < typeof BaseController , PollingInput > (
9798 BaseController ,
9899 ) ;
100+
101+ // The return type is inferred from the class defined inside the function
102+ // scope, so this can't be easily typed.
103+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
104+ export const StaticIntervalPollingDataService = < PollingInput extends Json > ( ) =>
105+ StaticIntervalPollingControllerMixin < typeof BaseDataService , PollingInput > (
106+ BaseDataService ,
107+ ) ;
Original file line number Diff line number Diff line change 11export {
22 BlockTrackerPollingControllerOnly ,
33 BlockTrackerPollingController ,
4+ BlockTrackerPollingDataService ,
45} from './BlockTrackerPollingController' ;
56
67export {
78 StaticIntervalPollingControllerOnly ,
89 StaticIntervalPollingController ,
10+ StaticIntervalPollingDataService ,
911} from './StaticIntervalPollingController' ;
1012
1113export type { IPollingController } from './types' ;
Original file line number Diff line number Diff line change 77 },
88 "references" : [
99 { "path" : " ../base-controller/tsconfig.build.json" },
10+ { "path" : " ../base-data-service/tsconfig.build.json" },
1011 { "path" : " ../controller-utils/tsconfig.build.json" },
1112 { "path" : " ../network-controller/tsconfig.build.json" },
1213 { "path" : " ../messenger/tsconfig.build.json" }
Original file line number Diff line number Diff line change 66 },
77 "references" : [
88 { "path" : " ../base-controller" },
9+ { "path" : " ../base-data-service" },
910 { "path" : " ../controller-utils" },
1011 { "path" : " ../network-controller" },
1112 { "path" : " ../messenger" }
Original file line number Diff line number Diff line change @@ -8029,6 +8029,7 @@ __metadata:
80298029 dependencies:
80308030 "@metamask/auto-changelog": "npm:^6.1.0"
80318031 "@metamask/base-controller": "npm:^9.1.0"
8032+ "@metamask/base-data-service": "npm:^0.1.3"
80328033 "@metamask/messenger": "npm:^1.2.0"
80338034 "@metamask/network-controller": "npm:^34.0.0"
80348035 "@metamask/utils": "npm:^11.11.0"
You can’t perform that action at this time.
0 commit comments