npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

openui5-redux-model

v0.4.1

Published

[![Travis](https://img.shields.io/travis/cevou/openui5-redux-model.svg?maxAge=2592000?style=flat-square)](https://travis-ci.org/cevou/openui5-redux-model) [![Coveralls](https://img.shields.io/coveralls/cevou/openui5-redux-model.svg?maxAge=2592000?style=fl

Downloads

8

Readme

OpenUI5 Redux Model

Travis Coveralls

This repository provides a OpenUI5 library to integrate OpenUI5 with Redux. This makes it possible to write applications with predictable state with SAP OpenUI5.

Redux is a predictable state container for JavaScript apps. It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test.

Install

To use this library download it via bower (like all other OpenUI5 packaged libraries).

bower install openui5-redux-model

Then list the library in the UI5 bootstrap tag.

<script id="sap-ui-bootstrap"
  src="resources/sap-ui-core.js"
  data-sap-ui-libs="redux">
</script>

Make sure that the library files are server in the right directory. This is dependent on from where you load the UI5 libraries.

You also need to integrate Redux somewhere in your application. It is not included with this library. You can do this by loading it from a CDN via a <script> tag or by including the redux.js file directly somewhere in your application.

By default Redux is available in a global variable. However, you can also include it via the UI5 module system. To do that you need to register it with the UI5 core.

jQuery.sap.registerModuleShims({
  'app/thirdparty/redux.min': {
    exports: 'Redux'
  }
});

Usage

To use the redux model you first have to instantiate a redux store. You can find more information about what options are available in the redux documentation. Then you can instantiate the Model and set it for the UI5 Core, your component, ....

var oStore = Redux.createStore(fnReducer);
var oModel = new ReduxModel(oStore);
sap.ui.getCore().setModel(oModel);

Now you can bind to the data in the store in your views by simply providing the path in the state (similar to a JSON model).

<Button text="{/test}" />

To update the data in your view you just dispatch actions via your store and process them using your reducer(s).

Advanced Usage

It is not a best practice to access data in your store directly because the structure of how your data is stored can easily change as you develop your application. The better approach is to use selectors with a defined API. This selectors are simple functions which get the current state passed as an argument and return data based on that.

You can use selectors with the redux model. Just pass an object with selector functions when you create your model.

<Button text="{/selector/selectorFunction}" />

All selector binding must start with /selector. The second part of the binding in property name of the object in which the selector is defined.

var oStore = Redux.createStore(fnReducer);
var oModel = new ReduxModel(oStore, {
  selectorFunction: function(state, context) {
    
  }
});
sap.ui.getCore().setModel(oModel);

The first on in the current state and the second one the (optional) context.