lss-inject

WebJar for lss-inject

License

License

MIT
GroupId

GroupId

org.webjars.bowergithub.lsspolymerelements
ArtifactId

ArtifactId

lss-inject
Last Version

Last Version

2.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

lss-inject
WebJar for lss-inject
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/LssPolymerElements/lss-inject

Download lss-inject

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bowergithub.lsspolymerelements/lss-inject/ -->
<dependency>
    <groupId>org.webjars.bowergithub.lsspolymerelements</groupId>
    <artifactId>lss-inject</artifactId>
    <version>2.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bowergithub.lsspolymerelements/lss-inject/
implementation 'org.webjars.bowergithub.lsspolymerelements:lss-inject:2.0.2'
// https://jarcasting.com/artifacts/org.webjars.bowergithub.lsspolymerelements/lss-inject/
implementation ("org.webjars.bowergithub.lsspolymerelements:lss-inject:2.0.2")
'org.webjars.bowergithub.lsspolymerelements:lss-inject:jar:2.0.2'
<dependency org="org.webjars.bowergithub.lsspolymerelements" name="lss-inject" rev="2.0.2">
  <artifact name="lss-inject" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bowergithub.lsspolymerelements', module='lss-inject', version='2.0.2')
)
libraryDependencies += "org.webjars.bowergithub.lsspolymerelements" % "lss-inject" % "2.0.2"
[org.webjars.bowergithub.lsspolymerelements/lss-inject "2.0.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

lss-inject

To install use: bower install --save lss-inject

LIVE DEMO AND API

Published on webcomponents.org

Senario:

---app-main
    --my-parent-component  <-- PROVIDER of user-manager.  user-manager lives in this component.
       -user-manager
       -component-a      
         -component-b
            -component-c
         -component-d
            -component-e
              -my-child-component   <-- needs access to user-manager becomes REQUESTER of user-manager
                -user-manager  
          -component-f
     --my-faq
     --my-feedback

How to use:

In this example we have a single instance component that is called user-manager that we would like to use in a child component nested deep in our app. Rather then binding the user-manager through the component tree in our app, we can simple provide and request the user-manager as seen below.

1. Provide your component in any parent component

class MyParentComponent extends LssProviderBehavior(Polymer.Element) {
  
    ready() {
        super.ready();    
        this.provideInstance("UserManager", this.$.userManager);
    }
}

2. Request your component from any child component

class MyChildComponent extends LssRequesterBehavior(Polymer.Element) {
    connectedCallback() {
         super.connectedCallback();
         var userManager = this.requestInstance("UserManager");
         userManager.ensureLoggedIn().
    }
}

Be both a requester and provider

class MyComponent extends LssProviderBehavior(LssRequesterBehavior(Polymer.Element)) {
   ready() {
        super.ready();    
        this.provideInstance("MyComponent", this);
   }
   
   connectedCallback() {
         super.connectedCallback();
         var userManager = this.requestInstance("UserManager");
         userManager.ensureLoggedIn().
   }
   
   onLogoutButtonClick(){
        var userManager = this.requestInstance("UserManager");
        if(userManager) 
            userManager.logout().
   }
}
org.webjars.bowergithub.lsspolymerelements

Titanium Elements

Sweet, useful, and simple progressive web components.

Versions

Version
2.0.2