---
title: Helper instance and class methods
description: "Define instance methods on a Helper and call Helper class methods such as `find` and `findOne` anywhere in the app lifecycle."
type: api-reference
tags: [js-api, helpers, methods]
v3_relevant: true
deprecated: false
---
# Helper instance and class methods

Define instance methods on a Helper and call Helper class methods such as `find` and `findOne` anywhere in the app lifecycle.

---

## Class methods

### Find a helper

Use the `findOne` class method to find an instance of a helper. You can provide a predicate to look for a specific helper on the screen:

```js
var instance = Fliplet.Helper.findOne({
  name: 'profile',
  fields: { name: 'john' }
});
```

### Find a list of helpers

Use the `find` class method to find a list of helper instances on a screen. You can provide a predicate to filter for specific helpers:

```js
var instances = Fliplet.Helper.find({
  name: 'profile'
});
```

---

## Instance methods

### Update fields

Use the `set` instance method to update fields and values at runtime. Given the following example:

```js
var profile;

Fliplet.Helper({
  name: 'profile',
  data: {
    firstName: 'John'
  },
  render: {
    ready: function () {
      profile = this;
    }
  }
});
```

See how the `firstName` property can be updated at anytime using a static value or using the result of a promise returned by a function:

```js
profile.set('firstName', 'Nick');

profile.set('firstName', function () {
  return Promise.resolve('Tony');
})
```

---

### Find all nested helpers

Use the `find` method to retrieve a list of all helpers nested in the current helper.

```html
<fl-helper name="quiz">
  <fl-helper name="results"></fl-helper>
</fl-helper>
```

```js
// Get a list of nested helpers by name
var foundHelpers = quiz.find({ name: 'results' });

// You can also use the shorthand
var foundHelpers = quiz.find('results');

// You can also provide a predicate function
var foundHelpers = quiz.find(function (instance) {
  return instance.name === 'results';
});
```

### Find a nested helper

```html
<fl-helper name="quiz">
  <fl-helper name="results"></fl-helper>
</fl-helper>
```

Use the `findOne` method to retrieve a helper nested in the current helper.

```js
// Get a nested helper by name
var helperInstance = quiz.findOne({ name: 'results' });

// You can also use the shorthand
var helperInstance = quiz.findOne('results');

// You can also provide a predicate function
var helperInstance = quiz.findOne(function (instance) {
  return instance.name === 'results';
});
```

### Find all children helpers

```html
<fl-helper name="quiz">
  <fl-helper name="results"></fl-helper>
</fl-helper>
```

Use the `children` method to retrieve a list of all direct child helpers nested in the current helper.

```js
// Get a list of direct child helpers by name
var foundHelpers = quiz.children({ name: 'results' });

// You can also use the shorthand
var foundHelpers = quiz.children('results');

// You can also provide a predicate function
var foundHelpers = quiz.children(function (instance) {
  return instance.name === 'results';
});
```

---

### Find all parents

```html
<fl-helper name="slide">
  <fl-helper name="quiz">
    <fl-helper name="results"></fl-helper>
  </fl-helper>
</fl-helper>
```

Use the `parents` method to retrieve a list of all parent helpers of the current helper. If a predicate object/function is provided, the list of parents are filtered accordingly.

```js
// Get a list of all parent helpers
var parents = result.parents();

// Get a list of all parent helpers by name
var parents = result.parents({ name: 'quiz' });

// You can also use the shorthand
var parents = result.parents('quiz');

// You can also provide a predicate function
var foundHelpers = quiz.parents(function (instance) {
  return instance.name === 'quiz';
});
```

---

### Find closest helper

```html
<fl-helper name="slide">
  <fl-helper name="quiz">
    <fl-helper name="results"></fl-helper>
  </fl-helper>
</fl-helper>
```

Use the `closest` method to retrieve the closest parent helper of the current helper that matches the provided predicate object/function, including itself.

```js
// Get the closest parent helpers by name
var closest = result.closest({ name: 'quiz' });

// You can also use the shorthand
var closest = result.closest('quiz');

// You can also provide a predicate function
var foundHelpers = quiz.closest(function (instance) {
  return instance.name === 'quiz';
});
```

---

## Define new instance methods

Instance methods can be defined via the `methods` property as shown in the example below:

```js
Fliplet.Helper({
  name: 'welcome',
  render: {
    methods: {
      greet: function () {
        console.log('Hello');
      }
    },
    ready: function () {
      // Greet once a button inside this helper is clickd
      this.$el.find('button').click(this.greet);
    }
  }
});
```

You can also keep a reference to a helper instance and call its methods any time:

```js
var welcome;

Fliplet.Helper({
  name: 'welcome',
  render: {
    methods: {
      greet: function () {
        console.log('Hello');
      }
    },
    ready: function () {
      welcome = this;
    }
  }
});

welcome.greet();
```

---

## Further reading

<section class="blocks alt">
  <a class="bl two" href="fields.html">
    <div>
      <span class="pin">Next article in this series</span>
      <h4>Attributes</h4>
      <p>Learn more about defining attributes and fields in your helpers.</p>
      <button>Next &rarr;</button>
    </div>
  </a>
</section>
