How to use framework - 10 common examples

To help you get started, we’ve selected a few framework examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ivan-kleshnin / unredux / examples / 7.1.crud / client / root / index.js View on Github external
// D.withLog({key}),
  )(
    // Init
    D.init(seed),
    D.initAsync(sources.state$),

    // Navigation
    intents.navigateTo$.map(url => R.fn("navigateTo", R.set("url", url))),
    intents.navigateHistory$.map(url => R.fn("navigateHistory", R.set("url", url))),

    // Content
    contentSinks$.flatMapLatest(x => x.action$),
  ).$

  // COMPONENT
  let Component = F.connect(
    {
      url: D.deriveOne(state$, ["url"]),
      Content: contentSinks$.map(x => x.Component),
    },
    ({url, Content}) => {
      return <div>
        <div>
          <p>
            Current URL: {url}
          </p>
          
        </div>
        <div>
          <content>
        </content></div>
      </div>
github ivan-kleshnin / unredux / examples / 7.1.crud / client / user-detail / index.js View on Github external
)

  // STATE
  let detail$ = D.run(
    () =&gt; D.makeStore({}),
    // D.withLog({key}),
  )(
    D.init(seed),

    D.ifBrowser(
      fetchStart$.merge(fetchEnd$.delay(1)).map(_ =&gt; R.over(["loading"], R.not))
    ),
  ).$

  // COMPONENT
  let Component = F.connect(
    {
      loading: D.deriveOne(detail$, ["loading"]),
      user: D.deriveOne(sources.state$, baseLens),
    },
    ({loading, user}) =&gt; loading
      ? 
      : 
  )

  // ACTION (external)
  let action$ = K.merge([
    fetchEnd$.map(user =&gt; {
      if (user) {
        return function afterGET(state) {
          return R.set(baseLens, user, state)
        }
github ivan-kleshnin / unredux / examples / 7.1.crud / client / post-detail / index.js View on Github external
)

  // STATE
  let detail$ = D.run(
    () =&gt; D.makeStore({}),
    // D.withLog({key}),
  )(
    D.init(seed),

    D.ifBrowser(
      fetchStart$.merge(fetchEnd$.delay(1)).map(_ =&gt; R.over(["loading"], R.not))
    ),
  ).$

  // COMPONENT
  let Component = F.connect(
    {
      loading: D.deriveOne(detail$, ["loading"]),
      post: D.deriveOne(sources.state$, baseLens),
    },
    ({loading, post}) =&gt; loading
      ? 
      : 
  )

  // ACTION (external)
  let action$ = K.merge([
    fetchEnd$.map(post =&gt; {
      if (post) {
        return function afterGET(state) {
          return R.set(baseLens, post, state)
        }
github shopsys / project-base / assets / js / frontend / product / productList.AjaxFilter.js View on Github external
});
    }

    static willFilterZeroProducts ($countElement) {
        return $countElement.html().indexOf('(0)') !== -1;
    }

    static init ($container) {
        if ($container.filterAllNodes('.js-product-list-with-paginator').length > 0) {
            // eslint-disable-next-line no-new
            new ProductListAjaxFilter($container);
        }
    }
}

(new Register()).registerCallback(ProductListAjaxFilter.init);
github shopsys / project-base / assets / js / frontend / components / HoverIntent.js View on Github external
const hideAllOpenedIntentsEvent = (event) => {
            if ($(event.target).closest('.js-hover-intent').length === 0) {
                HoverIntent.hideAllOpenedIntent(hoverIntentSettings);
            }
        };

        $('body').off('click', hideAllOpenedIntentsEvent);
        $('body').on('click', hideAllOpenedIntentsEvent);

        // eslint-disable-next-line no-new
        new HoverIntent(hoverIntentSettings);
    }
}

if (Responsive.isDesktopVersion()) {
    (new Register()).registerCallback(HoverIntent.init, 'HoverIntent.init');
}
github shopsys / project-base / assets / js / frontend / cart / CartBoxItemRemover.js View on Github external
if (data.success === true) {
                            $('#js-cart-box').trigger('reload');
                        } else {
                            // eslint-disable-next-line no-new
                            new Window({
                                content: data.errorMessage
                            });
                        }
                    }
                });
            });
        });
    }
}

(new Register()).registerCallback(CartBoxItemRemover.init, 'CartBoxItemRemover.init');
github digitalgreenorg / dg / dg / media / social_website / scripts / app / view-controllers / profile / ActivitiesViewController.js View on Github external
collectionStats.totalDuration += currentVideo.duration;

                        carouselSlide.push(currentVideo);

                        if ((j > 0 && (j + 1) % 3 == 0) || j == videosLen - 1) {
                            carouselSlides.push({
                                videos: carouselSlide
                            });
                            carouselSlide = [];
                        }
                    }

                    currentActivity.collection._carouselSlides = carouselSlides;

                    // format
                    collectionStats.likes = Util.integerCommaFormat(collectionStats.likes);
                    collectionStats.views = Util.integerCommaFormat(collectionStats.views);
                    collectionStats.adoptions = Util.integerCommaFormat(collectionStats.adoptions);
                    collectionStats.totalDuration = Util.secondsToHMSFormat(collectionStats.totalDuration);

                    currentActivity.collection._collectionStats = collectionStats;
                }
            }
        },
github digitalgreenorg / dg / dg / media / social_website / scripts / app / view-controllers / news / NewsFeedViewController.js View on Github external
collectionStats.totalDuration += currentVideo.duration;

                        carouselSlide.push(currentVideo);

                        if ((j > 0 && (j + 1) % 4 == 0) || j == videosLen - 1) {
                            carouselSlides.push({
                                videos: carouselSlide
                            });
                            carouselSlide = [];
                        }
                    }

                    currentActivity.collection._carouselSlides = carouselSlides;

                    // format
                    collectionStats.likes = Util.integerCommaFormat(collectionStats.likes);
                    collectionStats.views = Util.integerCommaFormat(collectionStats.views);
                    collectionStats.adoptions = Util.integerCommaFormat(collectionStats.adoptions);
                    collectionStats.totalDuration = Util.secondsToHMSFormat(collectionStats.totalDuration);

                    currentActivity.collection._collectionStats = collectionStats;
                }
            }
        },
github digitalgreenorg / dg / dg / media / social_website / scripts / app / view-controllers / news / NewsFeedViewController.js View on Github external
carouselSlide.push(currentVideo);

                        if ((j > 0 && (j + 1) % 4 == 0) || j == videosLen - 1) {
                            carouselSlides.push({
                                videos: carouselSlide
                            });
                            carouselSlide = [];
                        }
                    }

                    currentActivity.collection._carouselSlides = carouselSlides;

                    // format
                    collectionStats.likes = Util.integerCommaFormat(collectionStats.likes);
                    collectionStats.views = Util.integerCommaFormat(collectionStats.views);
                    collectionStats.adoptions = Util.integerCommaFormat(collectionStats.adoptions);
                    collectionStats.totalDuration = Util.secondsToHMSFormat(collectionStats.totalDuration);

                    currentActivity.collection._collectionStats = collectionStats;
                }
            }
        },
github digitalgreenorg / dg / media / social_website / scripts / app / controllers / ViewCollectionsController.js View on Github external
var $rightValue;
            var $statIndicator;

            var i = 0;
            var len = $statBarWrappers.length;
            for (; i &lt; len; i++) {
                var $currentStatBarWrapper = $statBarWrappers.eq(i);

                $statBar = $currentStatBarWrapper.find('.js-stat-bar');
                var leftValue = $statBar.data('leftValue');
                var rightValue = $statBar.data('rightValue');

                $leftValue = $currentStatBarWrapper.find('.js-left-value');
                $rightValue = $currentStatBarWrapper.find('.js-right-value');
                $leftValue.html(Util.integerCommaFormat(leftValue));
                $rightValue.html(Util.integerCommaFormat(rightValue));

                $statIndicator = $currentStatBarWrapper.find('.js-stat-indicator');

                // for basic width setting, use this line instead
                // $statIndicator.css('width', ((leftValue * 100) / (leftValue + rightValue)) + '%');

                // otherwise, this can be used to animate the effect
                $statIndicator.animate({
                    width: ((leftValue * 100) / (leftValue + rightValue)) + '%'
                }, 2000);

            }
        },