     public func saveStateOf<T:Codable>(_ value:T,identified byKey:String){
         if let value = try? JSON.encoder.encode(value){
             self.statesDictionary[byKey] = value
+            self.document?.hasChanged()
         }
     }
 

    public func saveStateString(_ string:String,identified byKey:String){
        if let data = Data(base64Encoded: string){
            self.statesDictionary[byKey] = data
        }
    }


import Foundation

public extension DocumentMetadata{

    public var document:BartlebyDocument? { return Bartleby.sharedInstance.getDocumentByUID(self.persistentUID) }

    public var debugTriggersHistory:Bool{ return true } // Should be set to False

