# Titanium.Proxy

> The base for all Titanium objects.

- Source: https://titaniumsdk.com/docs/sdk/12.6.3/Titanium.Proxy
- Titanium SDK version: 12.6.3
- Kind: proxy
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 0.1

On platforms that use native code (Android and iOS), the `Proxy` type represents a
JavaScript wrapper or _proxy_ around a native object. Setting or getting a property
on a proxy object results in a method invokation on the native object. Likewise,
calling a method on the proxy object results in a method invokation on the native
object.

Some Titanium objects are _createable_: new instances of these objects can be created using
factory methods. For example, a [Window](https://titaniumsdk.com/docs/sdk/Titanium.UI.Window.md) object can be created using the
[Titanium.UI.createWindow](https://titaniumsdk.com/docs/sdk/Titanium.UI.md#createWindow) method.

In general, developers should avoid modifying the prototype of a Titanium object, or
adding methods to a Titanium object. (Adding a simple property such as an ID value is
generally OK.)

## Properties

### apiName

- Type: String
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0
- Permission: read-only

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, [Button](https://titaniumsdk.com/docs/sdk/Titanium.UI.Button.md)
returns `Ti.UI.Button`.

### bubbleParent

- Type: Boolean
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0
- Default: `true`

Indicates if the proxy will bubble an event to its parent.

Some proxies (most commonly views) have a relationship to other proxies, often
established by the add() method. For example, for a button added to a window, a
click event on the button would bubble up to the window. Other common parents are
table sections to their rows, table views to their sections, and scrollable views
to their views. Set this property to false to disable the bubbling to the proxy's parent.

### lifecycleContainer

- Type: Titanium.UI.Window | Titanium.UI.TabGroup
- Platforms: Android
- Since: Titanium SDK 3.6.0

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks
will also be called on the proxy. Proxies that require the activity lifecycle will need this property set
to the appropriate containing Window or TabGroup.

## Methods

### addEventListener

- Platforms: Android, iPhone, iPad, macOS

Adds the specified callback as an event listener for the named event.

Parameters:

- `name` (String): Name of the event.
- `callback` (Callback<Titanium.Event>): Callback function to invoke when the event is fired.

### applyProperties

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 3.0.0

Applies the properties to the proxy.

Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that
myproxy[key] = value.

Parameters:

- `props` (Dictionary): A dictionary of properties to apply.

### fireEvent

- Platforms: Android, iPhone, iPad, macOS

Fires a synthesized event to any registered listeners.

Parameters:

- `name` (String): Name of the event.
- `event` (Dictionary, optional): A dictionary of keys and values to add to the [Titanium.Event](https://titaniumsdk.com/docs/sdk/Titanium.Event.md) object sent to the listeners.

### removeEventListener

- Platforms: Android, iPhone, iPad, macOS

Removes the specified callback as an event listener for the named event.

Multiple listeners can be registered for the same event, so the
`callback` parameter is used to determine which listener to remove.

When adding a listener, you must save a reference to the callback function
in order to remove the listener later:

``` js
var listener = function() { Ti.API.info("Event listener called."); }
window.addEventListener('click', listener);
```

To remove the listener, pass in a reference to the callback function:

``` js
window.removeEventListener('click', listener);
```

Parameters:

- `name` (String): Name of the event.
- `callback` (Callback<Titanium.Event>): Callback function to remove. Must be the same function passed to `addEventListener`.

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

