Sha256: 6e9f031a7f0c68f6a078349616f68e540bfbb4abc724f687d39025a131748814

Contents?: true

Size: 992 Bytes

Versions: 55

Compression:

Stored size: 992 Bytes

Contents

# *Flexirest:* Lazy loading

Flexirest supports lazy loading (delaying the actual API call until the response is actually used, so that views can be cached without still causing API calls).

**Note: Currently this isn't enabled by default, but this is likely to change in the future to make lazy loading the default.**

To enable it, simply call the lazy_load! method in your class definition:

```ruby
class Article < Flexirest::Base
  lazy_load!
end
```

If you have a ResultIterator that has multiple objects, each being lazy loaded or HAL linked resources that isn't loaded until it's used, you can actually parallelise the fetching of the items using code like this:

```ruby
items.parallelise(:id)

# or

items.parallelise do |item|
  item.id
end
```

This will return an array of the named method for each object or the response from the block and will have loaded the objects in to the resource.

-----

[< Using callbacks](using-callbacks.md) | [Authentication >](authentication.md)

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
flexirest-1.12.4 docs/lazy-loading.md
flexirest-1.12.3 docs/lazy-loading.md
flexirest-1.12.2 docs/lazy-loading.md
flexirest-1.12.1 docs/lazy-loading.md
flexirest-1.12.0 docs/lazy-loading.md
flexirest-1.11.3 docs/lazy-loading.md
flexirest-1.11.2 docs/lazy-loading.md
flexirest-1.11.1 docs/lazy-loading.md
flexirest-1.11.0 docs/lazy-loading.md
flexirest-1.10.12 docs/lazy-loading.md
flexirest-1.10.11 docs/lazy-loading.md
flexirest-1.10.10 docs/lazy-loading.md
flexirest-1.10.9 docs/lazy-loading.md
flexirest-1.10.8 docs/lazy-loading.md
flexirest-1.10.7 docs/lazy-loading.md
flexirest-1.10.6 docs/lazy-loading.md
flexirest-1.10.5 docs/lazy-loading.md
flexirest-1.10.4 docs/lazy-loading.md
flexirest-1.10.3 docs/lazy-loading.md
flexirest-1.10.2 docs/lazy-loading.md