from reactive import _


def printer(trace, *args, **kwargs):
    print 'Trace: ' + str(trace)


obj = _("Hello")

obj.oncompare(printer, args=(), kwargs={})

obj == " World"
Example #2
0
from reactive import _


def foo(bar=None, baz=None):
    print 'bar: ' + str(bar)
    print 'baz: ' + str(baz)
    return "Return Value"


def printer(trace, *args, **kwargs):
    print 'Trace: ' + str(trace)


foo_obj = _(foo)

foo_obj.after_call(printer, args=(), kwargs={})

foo_obj(bar=1)
from reactive import _

def printer(trace, message='Hello', *args, **kwargs):
  print 'Message: ' + str(message)

def hello_world(trace, name='Deepanshu', *args, **kwargs):
  print 'Hello ' + name + '!'
 
obj = _("Hello")

obj.onchange(printer, args=(), kwargs={'message': "Test"})\
  .onchange(hello_world, args=(), kwargs={})

obj += " World"
from reactive import _


def foo(trace, *args, **kwargs):
    print 'Trace: ' + str(trace)


class A:
    pass


# Create a new reactive <'type' int> object
obj = _(A())

obj.onchange(foo, args=(), kwargs={})

obj.a = 'B'
obj.a = 'C'
from reactive import _


def foo(trace, *args, **kwargs):
    print 'Trace: ' + str(trace)


# Create a new reactive list
obj = _([1, 2, 3, 4, 5])

obj.onchange(foo, args=(), kwargs={})

obj[2] = 4
from reactive import _

def foo(trace, *args, **kwargs):
  print 'Trace: ' + str(trace)

class A:
  pass

# Create a new reactive <'type' int> object
obj = _(A())

obj.onchange(foo, args=(), kwargs={})
 
obj.a = 'B'
obj.a = 'C'
from reactive import _

def printer(trace, message='Hello', *args, **kwargs):
  print 'Message: ' + str(message)
  print 'Trace: ' + str(trace) 
  print 'Args: ' + str(args)
  print 'Kwargs: ' + str(kwargs)
 
obj = _(1)

obj.onchange(printer, args=(), kwargs={'message': 'Test'})

obj += 1
from reactive import _


def foo(trace, *args, **kwargs):
    print 'Trace: ' + str(trace)


# Create a new reactive dict
obj = _({'a': 'b', 'c': 'd'})

obj.onchange(foo, args=(), kwargs={})

obj['e'] = 'f'
from reactive import _

def foo(trace, *args, **kwargs):
  print 'Trace: ' + str(trace)

# Create a new reactive <'type' int> object
obj = _(1)

obj.onchange(foo, args=(), kwargs={})

# Assign value 2 to the object while keeping all its hooks (onchange, oncompare, before_call, after_call, etc) if any, intact and trigger a onchange event simultaneously
 
obj._(2)
Example #10
0
from reactive import _

def foo(trace, *args, **kwargs):
  print 'Trace: ' + str(trace)

# Create a new reactive list
obj = _([1, 2, 3, 4, 5])

obj.onchange(foo, args=(), kwargs={})
 
obj[2] = 4
from reactive import _

def foo(bar=None, baz=None):
  print 'bar: ' + str(bar)
  print 'baz: ' + str(baz)
  return "Return Value"

def printer(trace, *args, **kwargs):
  print 'Trace: ' + str(trace)
 
foo_obj = _(foo)

foo_obj.after_call(printer, args=(), kwargs={})

foo_obj(bar=1)
Example #12
0
from reactive import _


def foo(trace, *args, **kwargs):
    print 'Trace: ' + str(trace)


# Create a new reactive tuple
obj = _(('a', 'b'))

obj.onchange(foo, args=(), kwargs={})

obj += ('c', 'd')
from reactive import _

def foo(trace, *args, **kwargs):
  print 'Trace: ' + str(trace)

# Create a new reactive tuple
obj = _(('a', 'b'))

obj.onchange(foo, args=(), kwargs={})
 
obj += ('c', 'd')