import { Serializer } from "ddd-base" ; export const AppPreferencesSerializer = { toJSON ( entity ) { return { ... entity } ; } , fromJSON ( json ) { return new AppPreferences ( { ... DefaultAppPreferences , ... json } ) ; } } ; export interface AppPreferencesJSON { prefetchSubscriptionCount : number ; fetchContentsCount : number ; enableAutoRefreshSubscription : boolean ; autoRefreshSubscriptionSec : number ; } export const DefaultAppPreferences = { fetchContentsCount : 20 , prefetchSubscriptionCount : 5 , enableAutoRefreshSubscription : true , autoRefreshSubscriptionSec : 120 } ; export class AppPreferences { prefetchSubscriptionCount : number ; fetchContentsCount : number ; enableAutoRefreshSubscription : boolean ; autoRefreshSubscriptionSec : number ; constructor ( args ) { this . prefetchSubscriptionCount = args . prefetchSubscriptionCount ; this . enableAutoRefreshSubscription = args . enableAutoRefreshSubscription ; this . autoRefreshSubscriptionSec = args . autoRefreshSubscriptionSec ; this . fetchContentsCount = args . fetchContentsCount ; } update ( newArgs ) { return new AppPreferences ( { ... ( this as AppPreferencesJSON ) , ... newArgs } ) ; } }