Imagine for a moment @trentmwillis Lazy Loading Engines: Anything - - PowerPoint PPT Presentation

imagine for a moment trentmwillis lazy loading engines
SMART_READER_LITE
LIVE PREVIEW

Imagine for a moment @trentmwillis Lazy Loading Engines: Anything - - PowerPoint PPT Presentation

Imagine for a moment @trentmwillis Lazy Loading Engines: Anything But Lazy Engines allow multiple logical applications to be composed together into a single application from the users perspective. - Engine RFC Lazy Loading Engines.


slide-1
SLIDE 1

Imagine for a moment…

slide-2
SLIDE 2
slide-3
SLIDE 3
slide-4
SLIDE 4
slide-5
SLIDE 5
slide-6
SLIDE 6
slide-7
SLIDE 7

@trentmwillis

slide-8
SLIDE 8
slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11

Lazy Loading Engines: Anything But Lazy

slide-12
SLIDE 12

Engines allow multiple logical applications to be composed together into a single application from the user’s perspective.

  • Engine RFC
slide-13
SLIDE 13

Lazy Loading Engines.

slide-14
SLIDE 14

Lazy Loading.

slide-15
SLIDE 15

Lazy Loading. It’s hard.

slide-16
SLIDE 16

Lazy Loading. It’s hard. But, Ember makes it easy.

slide-17
SLIDE 17

Problem 1: Serializing URLs

slide-18
SLIDE 18

How do we construct a URL to a lazily loaded route?

slide-19
SLIDE 19

{{#link-to “blog”}} Blog {{/link-to}}

slide-20
SLIDE 20

How to construct a URL Router + Model + Query Params + Route + Controller ——————— URL

slide-21
SLIDE 21

How to construct a URL Router + Model + Query Params + Route + Controller ——————— URL

slide-22
SLIDE 22

Problem 1: Serializing URLs

slide-23
SLIDE 23

Problem 1: Serializing URLs ————————————— Model Serialization w/o Routes Query Params w/o Controllers

slide-24
SLIDE 24

Model Serialization w/o Routes

slide-25
SLIDE 25

Router.map(function() { this.route('post', { path: ‘/post/:post_id’ }); });

slide-26
SLIDE 26

Route.extend({ serialize(model) { return { post_id: model.id }; } });

slide-27
SLIDE 27

Route Serializer RFC emberjs/rfcs#120

slide-28
SLIDE 28

[Replace] the existing Route#serialize method with an equivalent method

  • n the options hash passed into

this.route within Router#map.

slide-29
SLIDE 29

Route.extend({ serialize(model) { return { post_id: model.id }; } });

slide-30
SLIDE 30

function serialize(model) { return { post_id: model.id }; }

slide-31
SLIDE 31

function serialize(model) { return { post_id: model.id }; } Router.map(function() { this.route('post', { path: ‘/post/:post_id’, serialize }); });

slide-32
SLIDE 32

Query Params w/o Controllers

slide-33
SLIDE 33

Default Query Param Values

slide-34
SLIDE 34

Controller.extend({ queryParams: [‘lang’, ‘locale’], lang: ‘en’ });

slide-35
SLIDE 35

Controller.extend({ queryParams: [‘lang’, ‘locale’], lang: ‘en’ }); serialize({ });

slide-36
SLIDE 36

Controller.extend({ queryParams: [‘lang’, ‘locale’], lang: ‘en’ }); serialize({ lang: ‘en’, locale: ‘uk’ });

slide-37
SLIDE 37

Controller.extend({ queryParams: [‘lang’, ‘locale’], lang: ‘en’ }); serialize({ lang: ‘en’, locale: ‘uk’ }); => ?locale=uk

slide-38
SLIDE 38

Controller.extend({ queryParams: [‘lang’, ‘locale’], lang: ‘en’ }); serialize({ lang: ‘en’, locale: ‘uk’ }); => ?locale=uk&lang=en

slide-39
SLIDE 39

With lazy Engines, default query params are part of the URL

slide-40
SLIDE 40

Problem 2: Link Scoping

slide-41
SLIDE 41

{{link-to “blog”}}

slide-42
SLIDE 42

Where does

{{link-to “blog”}}

go in an Engine?

slide-43
SLIDE 43

{{link-to “blog”}}

slide-44
SLIDE 44

{{link-to “mountPoint.blog”}}

slide-45
SLIDE 45

To ensure isolation (and loose- coupling), links are scoped to an Engine’s mount point.

slide-46
SLIDE 46

How do you link outside the scope of an Engine?

slide-47
SLIDE 47

Engine Linking RFC emberjs/rfcs#122

slide-48
SLIDE 48

{{link-to-external “home”}} this.transitionToExternal(‘home’);

slide-49
SLIDE 49

export default Engine.extend({ dependencies: { externalRoutes: [ 'home', 'settings' ] } });

slide-50
SLIDE 50

Ember.Application.extend({ engines: { myEngine: { dependencies: { externalRoutes: { home: 'home.index', settings: 'user.settings' } } } } });

slide-51
SLIDE 51

With {{link-to-external}} you are specifying what you want to go to. It is the consumer’s responsibility to tell you where that is.

slide-52
SLIDE 52

Engine: Hey App, I want to go to “settings”. Where is that?

slide-53
SLIDE 53

Engine: Hey App, I want to go to “settings”. Where is that? Host: “settings” is located at “user.settings.index”.

slide-54
SLIDE 54

Engine: Hey App, I want to go to “settings”. Where is that? Host: “settings” is located at “user.settings.index”. Engine: Thanks!

slide-55
SLIDE 55

Problem 3: Loading Assets

slide-56
SLIDE 56

Problem 3: Loading Assets ———————————— What do we load? How do we load it?

slide-57
SLIDE 57

What do we load?

slide-58
SLIDE 58

Asset Manifest RFC emberjs/rfcs#153

slide-59
SLIDE 59

The Asset Manifest is a JSON specification to describe assets and bundles of assets that can be loaded into an Ember application asynchronously at runtime.

slide-60
SLIDE 60

interface Asset { type: String; uri: String; }

slide-61
SLIDE 61

type BundleName = string; interface Bundle { assets: Array<Asset>; dependencies?: Array<BundleName>; }

slide-62
SLIDE 62

interface AssetManifest { bundles: Map<BundleName, Bundle>; }

slide-63
SLIDE 63

Transforms (e.g., fingerprinting) Compositional Loading Extensibility Transferability

slide-64
SLIDE 64

How do we load it?

slide-65
SLIDE 65

Asset Loader RFC emberjs/rfcs#158

slide-66
SLIDE 66

The Asset Loader service is an Ember Service that is responsible for loading assets specified in an Asset Manifest.

slide-67
SLIDE 67

The API for loading these assets is Promise-based for integration with Router.js.

slide-68
SLIDE 68

interface AssetLoader { pushManifest(manifest: AssetManifest); };

slide-69
SLIDE 69

interface AssetLoader { pushManifest(manifest: AssetManifest); loadAsset(asset: Asset): AssetPromise; };

slide-70
SLIDE 70

interface AssetLoader { pushManifest(manifest: AssetManifest); loadAsset(asset: Asset): AssetPromise; loadBundle(bundle: BundleName): BundlePromise; };

slide-71
SLIDE 71

interface AssetLoader { pushManifest(manifest: AssetManifest); loadAsset(asset: Asset): AssetPromise; loadBundle(bundle: BundleName): BundlePromise; defineLoader(type: String, loader: (uri: String) => Promise<T, U>); };

slide-72
SLIDE 72

interface AssetLoader { pushManifest(manifest: AssetManifest); loadAsset(asset: Asset): AssetPromise; loadBundle(bundle: BundleName): BundlePromise; defineLoader(type: String, loader: (uri: String) => Promise<T, U>); };

slide-73
SLIDE 73

Asset Manifest + Asset Loader —————————————- Ember Asset Loading Strategy

slide-74
SLIDE 74

ember-asset-loader

slide-75
SLIDE 75

Ember Engines

slide-76
SLIDE 76

Ember Engines: A community-driven solution to lazy loading.

slide-77
SLIDE 77

ember-engines.com github.com/ember-engines

slide-78
SLIDE 78

Lazy Loading Engines: Anything But Lazy