Jump to content

Search the Community

Showing results for tags 'proxy'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

There are no results to display.

Forums

  • Welcome to Smart Mobile Studio
    • News and Information
    • Pre-Sales Questions
    • Smart In the Media
    • Smart Contests
    • Meta
  • Smart Mobile Studio Discussion
    • General
    • IDE
    • RTL
    • Code
    • Client Server
    • Platform
    • Graphics
    • Deployment
    • Suggestion box
  • Smart Mobile Studio support
    • Support
    • Bug report
  • General Discussion
    • Pascal
    • Delphi
    • Javascript
    • HTML/HTML5
    • CSS
  • Resources
    • Website
    • Download Smart Mobile Studio

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Company name


Position

Found 1 result

  1. lynkfs

    proxy

    I recently came across the javascript proxy object A proxy object basically monitors a chosen object, and has getter and setter functions which are invoked when the value of any of its properties changes (set) or are being accessed (get). In that respect there are some similarities with the mutationobserver object. In the below code snippet a regular EditBox has its text saved in a proxied object, which triggers the setter function and a Button which reads that value and thus triggers the getter function procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components var Edit1 : TW3EditBox := TW3EditBox.Create(self); Edit1.SetBounds(32,40,300,32); var Button1 : TW3Button := TW3Button.Create(self); Button1.SetBounds(340,40,200,32); Button1.Caption := 'read'; var Memo1 : TW3Memo := TW3Memo.Create(self); Memo1.SetBounds(32,90,300,100); //set proxies var MyProxy : variant := new JObject; var ProxyObj : variant := new JObject; ProxyObj.EditBox1 := 'initialvalue'; //will be overwritten Edit1.OnInput := lambda MyProxy.EditBox1 := Edit1.Text; end; //triggers 'handler.set' Button1.OnClick := lambda Button1.Caption := MyProxy.EditBox1; end; //triggers 'handler.get' var handler : variant := new JObject; handler.get := function(obj, prop: variant): variant begin Memo1.Add('someone read ' + prop + ' as ' + obj[prop] + #10); result := obj[prop]; end; handler.set := function(obj, prop, value: variant):variant begin Memo1.Add('someone set ' + prop + ' to ' + value + #10); obj[prop] := value; result := true; end; asm @MyProxy = new Proxy(@ProxyObj,@handler); end; end; This mechanism could f.i. be used to bind form components with a data source, updating them automatically when data changes or is being accessed Demo
×
×
  • Create New...